943,785 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2941
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
May 8th, 2008
0

Re: please help me in drop down list

hi, ok i tried to print this value: $firstdropdownlistvalue = $_POST['col_name'];
by echo($firstdropdownlistvalue);
but it's doesn't appeared in the browser. why?
Reputation Points: 10
Solved Threads: 0
Light Poster
almualim is offline Offline
28 posts
since May 2008
May 8th, 2008
0

Re: please help me in drop down list

Post your latest code.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 8th, 2008
0

Re: please help me in drop down list

okay:

php Syntax (Toggle Plain Text)
  1. <?php
  2. mysql_connect ("localhost","root","");
  3. mysql_select_db ("University");
  4.  
  5. $firstdropdownlistvalue = $_POST['col_name'];
  6.  
  7. $get_list_result = mysql_query("select Col_Name from College");
  8.  
  9. echo '<form name="delete" method="POST" action="delete_dept2.php">';
  10.  
  11. echo'<select name=col_name onchange=javascript: document.delete.submit(); style="position:absolute;left:311px;top:146px;width:303px;z-index:2">';
  12. while ($recs = mysql_fetch_array($get_list_result)){
  13.  
  14. $display_list = $recs['Col_Name'];
  15. if($display_list==$firstdropdownlistvalue){
  16. $selected = "selected";
  17. }
  18. else
  19. { $selected = "";
  20. }
  21. echo "<option value='".$display_list."' $selected>" .$display_list."</option>";
  22. }
  23. echo "</select>";
  24. echo ($firstdropdownlistvalue);
  25.  
  26. $get_list_result2 = mysql_query("select * from College where Col_Name='$firstdropdownlistvalue'");
  27. $get_list_result3= mysql_query("select D_Name from Department where Col_No='$get_list_result2'");
  28.  
  29. echo'<select name="formselect2" style="position:absolute;left:310px;top:223px;width:308px;z-index:4">';
  30. while ($recs2 = mysql_fetch_array($get_list_result3)){
  31.  
  32. $display_list2 = $recs2['D_Name'];
  33.  
  34. echo "<option value='".$display_list2."'> $display_list2 </option>";
  35. }
  36. echo '</select>';
  37. ?>
Last edited by peter_budo; May 11th, 2008 at 11:19 am. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 0
Light Poster
almualim is offline Offline
28 posts
since May 2008
May 8th, 2008
0

Re: please help me in drop down list

onchange="javascript: document.delete.submit();" instead of
onchange=javascript: document.delete.submit();

Secondly,
Quote ...
$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'");
is wrong. What are you trying to do ?
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 8th, 2008
0

Re: please help me in drop down list

see the last update on the code:

php Syntax (Toggle Plain Text)
  1. <?php
  2. mysql_connect ("localhost","root","");
  3. mysql_select_db ("University");
  4.  
  5. $firstdropdownlistvalue = $_POST['col_name'];
  6.  
  7. $get_list_result = mysql_query("select Col_Name from College");
  8.  
  9. echo '<form name="delete" method="POST" action="delete_dept2.php">';
  10.  
  11. echo'<select name=col_name onchange="javascript: document.delete.submit();" style="position:absolute;left:311px;top:146px;width:303px;z-index:2">';
  12. while ($recs = mysql_fetch_array($get_list_result)){
  13.  
  14. $display_list = $recs['Col_Name'];
  15. if($display_list==$firstdropdownlistvalue){
  16. $selected = "selected";
  17. }
  18. else
  19. { $selected = "";
  20. }
  21. echo "<option value='".$display_list."' $selected>" .$display_list."</option>";
  22. }
  23. echo "</select>";
  24. echo ($firstdropdownlistvalue);
  25.  
  26. $get_list_result2 = mysql_query("select col_No from College where Col_Name='$firstdropdownlistvalue'");
  27. while ($recs2 = mysql_fetch_array($get_list_result2)){
  28.  
  29. $display_list2 = $recs2['col_No'];
  30. }
  31.  
  32.  
  33.  
  34. $get_list_result3= mysql_query("select D_Name from Department where Col_No='$$display_list2'");
  35.  
  36. echo'<select name="formselect2" style="position:absolute;left:310px;top:223px;width:308px;z-index:4">';
  37. while ($recs3 = mysql_fetch_array($get_list_result3)){
  38.  
  39. $display_list3 = $recs3['D_Name'];
  40.  
  41. echo "<option value='".$display_list3."'> $display_list3 </option>";
  42. }
  43. echo '</select>';
  44. ?>


PHP Syntax (Toggle Plain Text)
  1. $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
Reputation Points: 10
Solved Threads: 0
Light Poster
almualim is offline Offline
28 posts
since May 2008
May 8th, 2008
0

Re: please help me in drop down list

Then use a sub query.
php Syntax (Toggle Plain Text)
  1. $query = "select D_Name from Department where col_No = (select col_No from College where col_name = '$firstdropdownlistvalue')";
This will return the D_name of the selected col_name.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 8th, 2008
0

Re: please help me in drop down list

Tired with me, but the problem still exist and I do not know what to do...
Last edited by almualim; May 8th, 2008 at 9:37 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
almualim is offline Offline
28 posts
since May 2008
May 8th, 2008
0

Re: please help me in drop down list

Use firefox to execute your scripts. Make use of error console to see any javascript error.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 8th, 2008
0

Re: please help me in drop down list

i tried with firefox, but when i was select value from 1st dropdown list Transmission occurs for the second page, but i want the values appear in the same page.
Reputation Points: 10
Solved Threads: 0
Light Poster
almualim is offline Offline
28 posts
since May 2008
May 8th, 2008
0

Re: please help me in drop down list

What second page ? Why dont you keep everything in the same page ?
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Refresh + Combo Box
Next Thread in PHP Forum Timeline: need php codings for my task!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC