| | |
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 |
ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link list login loop mail mediawiki menu mlm multiple mycodeisbad mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search seo server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign websphere white xml youtube






