Jump to content

Writing varible from option description


wolfkettler

Recommended Posts

Hi

 

I am trying to figure out whether I can write a variable from a description of a selected option field:

 

I am creating a dropdown selection box from values held in a MySQL database with this code:

<select name="amount">
<?php
$query = "SELECT * FROM Pricelist WHERE priceGroup = '$price_query' ";
$result = mysql_query("$query");
while ($row = mysql_fetch_array($result))
{
echo('<option value="') . ($row['amount']) . ('">') . ($row['description']) . ('</option>');
}
?>

 

So far, all this works perfectly well. Script makes dropdown selection box, user selects an option and the amount is passed to a Paypal shopping cart.

 

Now, however, I want to write a variable from the selected 'description', i.e. the text associated with the selected option value.

 

Would anyone know if this can be done (and how)?

 

Thanks,

Wolf

www.wolfkettler.co.uk

Link to comment
https://forums.phpfreaks.com/topic/126036-writing-varible-from-option-description/
Share on other sites

i think you would need to do a revers query to get it something like this

$query="SELECT `description` FROM `Pricelist` WHERE `amount` = '{$amount}'";
$result = mysql_query($query);
$description = mysql_result($result,0);

 

Scott.

Archived

This topic is now archived and is closed to further replies.

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