RE: [PHP-DB] Another dynamic sql.
| From: | Gurhan Ozen | Date: | Fri, 25 Jan 2002 19:11:05 +0000 |
| Subject: | RE: [PHP-DB] Another dynamic sql. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16176@lists.php.net to get a copy of this message | ||
Seems like it will NOT work because you are selecting $car which is already
chosen by the user (i.e. which is a known value). I don't know how you laid
out your table but shouldn't your query be something like "SELECT price from
FROM varetabell where carid=$car" ??
Gurhan
-----Original Message-----
From: Raymond Lilleodegard [mailto:raymol@online.no]
Sent: Friday, January 25, 2002 1:48 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Another dynamic sql.
Hi all!
I have this form with some choices:
<form>
Enter how many cars you want:<input type="text" name="number" >
<select size="1" name="car">
<option selected>ford</option>
<option>bmw</option>
<option>mercedes</option>
</select>
And then I am trying to get the price out of a table in my database with
this code:
$sql = mysql_query("SELECT '$car' FROM varetabell where carid='$carid'
");
$myrow= mysql_fetch_array($sql);
$x = $myrow["$car"];
$price = $x * $number;
Shouldn't this work? Or am I missing something here?
Best regards Raymond
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net