Jump to content

PHP and database retrieval with drop down box


redsent

Recommended Posts

I can't get it to use the item that is selected in the drop down box as the variable $va in the bit where it then queries the data base to retrieve only the line in the able that match the program_name with variable $va. variable $va would be the result of the drop down box.

 

Below is the code i have so far, any help would be appreciated.

 

Cheers.

 

<?php
include ('dbConn.php');

mysql_select_db($dbselect, $con);

$QuerySelects = "SELECT program_name FROM program_names";
$Query = mysql_query($QuerySelects) or die (mysql_errno() . ": " . mysql_error(). "\n");

echo '<label>Select Store:</label>';
echo '<select id="program_name"  name="program_name">';
echo '<option value="va">Select Store</option>';

while ($row = mysql_fetch_assoc($Query))
{
$va = $row['program_name'];
echo "<option value=''>$va</option>";
}
echo '</select>';



$QuerySelects1 = "SELECT * FROM offers1 WHERE end_date>CURDATE() AND program_name = '$va'";
$Query1 = mysql_query($QuerySelects1) or die (mysql_errno() . ": " . mysql_error(). "\n");



while($result=mysql_fetch_assoc($Query1)) {
include ('variables.php');
echo"
<div class='spacerbox'>
<div class='outerbox eviecodes'>
<div><div class='topbox'>
	<div class='leftbox'>
		<div class='offerimage'>
			<div class='progdiv'><a class='progname' href=".$url." target='_blank'>".$program_name."</a></div>
</div>
	</div>
	<div class='rightbox'><div class='descbox boxwidth'><h1>
		<a href=".$url." target='_blank'>".$description." at ".$program_name."</a></h1></div>
	<div class='voubox boxwidth'><h2 class='vvv'>Voucher Code:<span class='vcode'>".$code."</span ></h2></div>

</div>
</div>
<div class='linkbox boxwidthl'>
		<a href=".$url." target='_blank'>To Take Advantage of this offer at <span class='prodname'>".$program_name."</span>, click here!</a>
	</div>
<div class='expires'>
<span class='end'>Expires:</span> <span>".$dateformat."</span >
</div>
<div class='socialbox'>
{module Tell A Friend Module}
</div></div>
<div class='spacer'>
</div>
</div>
</div>
";
}
?>

Link to comment
Share on other sites

change these lines here:

$va = $row['program_name'];
echo "<option value=''>$va</option>";

To the following:

$va = $row['program_name'];
echo "<option value='$va'>$va</option>";

It is the "value" of the option that is passed as contnent information, the text between the tags is simply for the end users benefit.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.