User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2008
Posts: 24
Reputation: almualim is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
almualim almualim is offline Offline
Newbie Poster

Re: please help me in drop down list

  #11  
May 8th, 2008
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?
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: please help me in drop down list

  #12  
May 8th, 2008
Post your latest code.
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*
Reply With Quote  
Join Date: May 2008
Posts: 24
Reputation: almualim is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
almualim almualim is offline Offline
Newbie Poster

Re: please help me in drop down list

  #13  
May 8th, 2008
okay:

  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 10:19 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: please help me in drop down list

  #14  
May 8th, 2008
onchange="javascript: document.delete.submit();" instead of
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'");
is wrong. What are you trying to do ?
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*
Reply With Quote  
Join Date: May 2008
Posts: 24
Reputation: almualim is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
almualim almualim is offline Offline
Newbie Poster

Re: please help me in drop down list

  #15  
May 8th, 2008
see the last update on the code:

  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. ?>


$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
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: please help me in drop down list

  #16  
May 8th, 2008
Then use a sub query.
  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.
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*
Reply With Quote  
Join Date: May 2008
Posts: 24
Reputation: almualim is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
almualim almualim is offline Offline
Newbie Poster

Re: please help me in drop down list

  #17  
May 8th, 2008
Tired with me, but the problem still exist and I do not know what to do...
Last edited by almualim : May 8th, 2008 at 8:37 am.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: please help me in drop down list

  #18  
May 8th, 2008
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*
Reply With Quote  
Join Date: May 2008
Posts: 24
Reputation: almualim is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
almualim almualim is offline Offline
Newbie Poster

Re: please help me in drop down list

  #19  
May 8th, 2008
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.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: please help me in drop down list

  #20  
May 8th, 2008
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*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:42 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC