Re: Another dynamic sql.
| From: | Raymond Lilleødegård | Date: | Fri, 25 Jan 2002 19:22:08 +0000 |
| Subject: | Re: Another dynamic sql. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16177@lists.php.net to get a copy of this message | ||
My example was a litle confusing here I see.
My table have multiple price columns. something like this:
carid convertible stationvagon etc. etc
1 100 100 100
----- Original Message -----
From: "Gurhan Ozen" <c-gurhan.ozen@wcom.com>
To: "Raymond Lilleodegard" <raymol@online.no>; <php-db@lists.php.net>
Sent: Friday, January 25, 2002 8:11 PM
Subject: RE: [PHP-DB] Another dynamic sql.
> 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
>
>