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,798 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,372 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: 3927 | Replies: 1
Reply
Join Date: Jul 2006
Posts: 6
Reputation: tzan2833 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tzan2833 tzan2833 is offline Offline
Newbie Poster

bringing data from mysql using select box

  #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 5:50 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Location: Canada
Posts: 55
Reputation: GliderPilot is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
GliderPilot's Avatar
GliderPilot GliderPilot is offline Offline
Junior Poster in Training

Re: bringing data from mysql using select box

  #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:


<?php
 
$selected = $_POST['selected'];
 
if ($selected != "")
{
  // MySQL commands to retrieve the info depending on what was selected
}
 
?>
 
//Page Code Here
 
 
 
<form action="thispage.php" method="post" name="first_form">
 
<select name="first_select" onChange="document.first_form.submit();">
 
</form>
 
<form action="search.php" method="post" name="second_form">
 
<?php
 
//Use a for loop to go through the array of info recieved from the database and populate the second select field
 
?>
 
<input type="submit>
 
</form>
 

Hope this helps


Last edited by GliderPilot : Sep 21st, 2006 at 3:42 pm.
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 5:51 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC