•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,838 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,604 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 977 | Replies: 21
![]() |
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
•
•
Join Date: May 2008
Posts: 24
Reputation:
Rep Power: 1
Solved Threads: 0
okay:
php Syntax (Toggle Plain Text)
<?php mysql_connect ("localhost","root",""); mysql_select_db ("University"); $firstdropdownlistvalue = $_POST['col_name']; $get_list_result = mysql_query("select Col_Name from College"); echo '<form name="delete" method="POST" action="delete_dept2.php">'; echo'<select name=col_name onchange=javascript: document.delete.submit(); style="position:absolute;left:311px;top:146px;width:303px;z-index:2">'; while ($recs = mysql_fetch_array($get_list_result)){ $display_list = $recs['Col_Name']; if($display_list==$firstdropdownlistvalue){ $selected = "selected"; } else { $selected = ""; } echo "<option value='".$display_list."' $selected>" .$display_list."</option>"; } echo "</select>"; echo ($firstdropdownlistvalue); $get_list_result2 = mysql_query("select * from College where Col_Name='$firstdropdownlistvalue'"); $get_list_result3= mysql_query("select D_Name from Department where Col_No='$get_list_result2'"); echo'<select name="formselect2" style="position:absolute;left:310px;top:223px;width:308px;z-index:4">'; while ($recs2 = mysql_fetch_array($get_list_result3)){ $display_list2 = $recs2['D_Name']; echo "<option value='".$display_list2."'> $display_list2 </option>"; } echo '</select>'; ?>
Last edited by peter_budo : May 11th, 2008 at 10:19 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
onchange="javascript: document.delete.submit();" instead of
onchange=javascript: document.delete.submit();
Secondly, is wrong. What are you trying to do ?
onchange=javascript: document.delete.submit();
Secondly,
•
•
•
•
$get_list_result2 = mysql_query("select * from College where Col_Name='$firstdropdownlistvalue'");
$get_list_result3= mysql_query("select D_Name from Department where Col_No='$get_list_result2'");
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: May 2008
Posts: 24
Reputation:
Rep Power: 1
Solved Threads: 0
see the last update on the code:
here i want to get college_no(col_No) from college table, if the college name(col_Name) equals the value came from 1st dropdown list($firstdropdownlistvalue)
and here i want to get department name(D_Name) from Department table, if college_no(col_No) equals $display_list2
php Syntax (Toggle Plain Text)
<?php mysql_connect ("localhost","root",""); mysql_select_db ("University"); $firstdropdownlistvalue = $_POST['col_name']; $get_list_result = mysql_query("select Col_Name from College"); echo '<form name="delete" method="POST" action="delete_dept2.php">'; echo'<select name=col_name onchange="javascript: document.delete.submit();" style="position:absolute;left:311px;top:146px;width:303px;z-index:2">'; while ($recs = mysql_fetch_array($get_list_result)){ $display_list = $recs['Col_Name']; if($display_list==$firstdropdownlistvalue){ $selected = "selected"; } else { $selected = ""; } echo "<option value='".$display_list."' $selected>" .$display_list."</option>"; } echo "</select>"; echo ($firstdropdownlistvalue); $get_list_result2 = mysql_query("select col_No from College where Col_Name='$firstdropdownlistvalue'"); while ($recs2 = mysql_fetch_array($get_list_result2)){ $display_list2 = $recs2['col_No']; } $get_list_result3= mysql_query("select D_Name from Department where Col_No='$$display_list2'"); echo'<select name="formselect2" style="position:absolute;left:310px;top:223px;width:308px;z-index:4">'; while ($recs3 = mysql_fetch_array($get_list_result3)){ $display_list3 = $recs3['D_Name']; echo "<option value='".$display_list3."'> $display_list3 </option>"; } echo '</select>'; ?>
$get_list_result2 = mysql_query("select col_No from College where Col_Name='$firstdropdownlistvalue'"); here i want to get college_no(col_No) from college table, if the college name(col_Name) equals the value came from 1st dropdown list($firstdropdownlistvalue)
$get_list_result3= mysql_query("select D_Name from Department where col_No='$display_list2'");
and here i want to get department name(D_Name) from Department table, if college_no(col_No) equals $display_list2
Last edited by peter_budo : May 11th, 2008 at 10:20 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
Then use a sub query.
This will return the D_name of the selected col_name.
php Syntax (Toggle Plain Text)
$query = "select D_Name from Department where col_No = (select col_No from College where col_name = '$firstdropdownlistvalue')";
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
Use firefox to execute your scripts. Make use of error console to see any javascript error.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
What second page ? Why dont you keep everything in the same page ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- php mysql drop down list (PHP)
- drop down list question. (ASP.NET)
- Populate One Drop Down List From Another (ASP.NET)
- Populating a Drop-down List (PHP)
- view employee info for the employee selected from the drop down list (PHP)
- Data Binding to a Drop Down List? (ASP.NET)
- Passing a drop down list item's value (HTML and CSS)
- Blank drop list (PHP)
Other Threads in the PHP Forum
- Previous Thread: Refresh + Combo Box
- Next Thread: need php codings for my task!



Linear Mode