bringing data from mysql using select box

Reply

Join Date: Jul 2006
Posts: 6
Reputation: tzan2833 is an unknown quantity at this point 
Solved Threads: 0
tzan2833 tzan2833 is offline Offline
Newbie Poster

bringing data from mysql using select box

 
0
  #1
Sep 21st, 2006
Dear all

I need to build a search with 2 select boxes like;

Search

I need the second box to be populated according to the first. (The first one will be populated by me and not from the database with 5 or 6 values).

After the second drop down is populated I need after selecting a value data from the database to come up according to the selection while one cell’s values to be hyperlinked.

TITLE REFERENCE COUNTRY YEAR
Computer science Willey and Sons England 1997
Environment in the 21st Howard publications Germay 2001


After selecting one hyperlinked value the full study will come up in table format.


Many thanks in advance

Best Regards.
Last edited by tzan2833; Sep 21st, 2006 at 6:50 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 57
Reputation: GliderPilot is an unknown quantity at this point 
Solved Threads: 2
GliderPilot's Avatar
GliderPilot GliderPilot is offline Offline
Junior Poster in Training

Re: bringing data from mysql using select box

 
0
  #2
Sep 21st, 2006
In order to change something on the fly you would have to use Javascript.... However javascript cannot activate a PHP statement because it is a server side script and Javascript is client side.

You would have to use javascript to Submit the form when something is selected, and have the form reload the page with the selection. Than have PHP read the selection, and populate the second Select box from the database.

For example:


  1. <?php
  2.  
  3. $selected = $_POST['selected'];
  4.  
  5. if ($selected != "")
  6. {
  7. // MySQL commands to retrieve the info depending on what was selected
  8. }
  9.  
  10. ?>
  11.  
  12. //Page Code Here
  13.  
  14.  
  15.  
  16. <form action="thispage.php" method="post" name="first_form">
  17.  
  18. <select name="first_select" onChange="document.first_form.submit();">
  19.  
  20. </form>
  21.  
  22. <form action="search.php" method="post" name="second_form">
  23.  
  24. <?php
  25.  
  26. //Use a for loop to go through the array of info recieved from the database and populate the second select field
  27.  
  28. ?>
  29.  
  30. <input type="submit>
  31.  
  32. </form>
  33.  

Hope this helps


Last edited by GliderPilot; Sep 21st, 2006 at 4:42 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC