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:[EMAIL PROTECTED]]
Sent: Friday, January 25, 2002 1:48 PM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to