| | |
please help me in drop down list
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 28
Reputation:
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 11:19 am. Reason: Keep It Organized - please use [code] tags
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'");
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: May 2008
Posts: 28
Reputation:
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>'; ?>
PHP Syntax (Toggle Plain Text)
$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 11:20 am. Reason: Keep It Organized - please use [code] tags
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')";
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
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!
| Thread Tools | Search this Thread |
.htaccess ajax apache api array back basic beginner binary broken cakephp checkbox class cms code computing cron curl customizableitems database date delete display dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validation validator variable video web xml youtube






