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.

Recommended Answers

All 3 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.