wolfkettler Posted September 27, 2008 Share Posted September 27, 2008 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 More sharing options...
ratcateme Posted September 27, 2008 Share Posted September 27, 2008 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. Link to comment https://forums.phpfreaks.com/topic/126036-writing-varible-from-option-description/#findComment-651775 Share on other sites More sharing options...
wolfkettler Posted September 27, 2008 Author Share Posted September 27, 2008 Hm, interesting approach but wouldn't work in my example because, whilst all descriptions are unique, some amounts are the same and some are different. Wolf Link to comment https://forums.phpfreaks.com/topic/126036-writing-varible-from-option-description/#findComment-651805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.