1,105,546 Community Members

Dynamic drop down menu to select records from Database

Member Avatar
patrick1981
Newbie Poster
19 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Hey fellows, I have three database tables

AUCTIONS
auction_id
name
description
place
date

BIDDERS
bidder_id
firstname
lastname
email
signupdate

BIDS
bid_id
auction_id
bidder_id
biddate


I want to create a drop down menu to select and display BIDDERS signed up for each AUCTIONS. I have coded the following in PHP to select the auction_id and title from AUCTIONS table into the drop down list.

<!-- Assuming connected to mysql database -->
<form id="form1" name="form1" method="post" action="">
<?php
 $query="SELECT * FROM auctions";
 $result =mysql_query($query,);
 $options="";
 while ($row=mysql_fetch_array($result)) {
  $auction_id=$row["auction_id"];
 $name=$row["name"];
 $options.="<OPTION VALUE=\"$auction_id\">".$name.'</option>';
}
?>
 Auction:
<select name="select" id="select">
<option value="Select All">Select All</option>
<?=$options?>
</select>
</form>

I want that when the user selects an option it displays the list of bidders entered to that particular auction using auction_id as their reference without submit button. Any ideas? Thank you.

Member Avatar
veedeoo
Veteran Poster
1,016 posts since Oct 2011
Reputation Points: 314 [?]
Q&As Helped to Solve: 166 [?]
Skill Endorsements: 17 [?]
 
0
 

This is our point of interest

<select name="select" id="select">

Process the form by either GET or POST

## grab the selected aution id
$a_id = $_POST['select'];

$query1 = "SELECT * FROM auctions WHERE auction_id = '".$a_id."'";
$result1 =mysql_query($query1,);
while ($row=mysql_fetch_array($result1)) {

## echo item title description, and all other stuffs
echo $row['title'];
}

That's all..

Member Avatar
patrick1981
Newbie Poster
19 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

This is our point of interest

<select name="select" id="select">

Process the form by either GET or POST

## grab the selected aution id
$a_id = $_POST['select'];

$query1 = "SELECT * FROM auctions WHERE auction_id = '".$a_id."'";
$result1 =mysql_query($query1,);
while ($row=mysql_fetch_array($result1)) {

## echo item title description, and all other stuffs
echo $row['title'];
}

That's all..

Thank you veedoo, actually the form is supposed to select the auction_id from the drop down parse it to the a new query that will pull and display records from BIDDERS table with that auction_id. The code to process the results to display will be like this

<?php 
if (isset($_POST['select'])) {
 $auction_id = $_POST['auction_id'];
 $query = "SELECT * FROM bidders WHERE auction_id = $auction_id";
 $result = mysql_query($query); 

// Print the result

while ($row = mysql_fetch_assoc($result)) {
 echo $row['bidder_id'];
 echo $row['firstname'];
 echo $row['lastname'];
 echo $row['signupdate'];
}
?>

But I want the form to run when you user select and click the value in the drop down menu down menu without clicking any submit button on the form.

Member Avatar
karthik_ppts
Posting Pro
574 posts since Feb 2011
Reputation Points: 81 [?]
Q&As Helped to Solve: 101 [?]
Skill Endorsements: 1 [?]
 
0
 
Question Answered as of 2 Years Ago by karthik_ppts and veedeoo
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: