With my respects to your design may I suggest the following: 1- Table: CARS car_id car_name active_flag price 1 BMW Y 100 2 FORD Y 50 etc.....
Then in your form you can hava a dynamic LOV: $sql = "select car_id, car_name from cars where active_flag = 'Y'"; $result = mysql_query($sql); echo "<select name = 'car' >"; while (list($car_id,$car_name)=mysql_fetch_array($result)) { echo "<option value='$car_id'>$carname</option>"; } echo "</select>"; Then when the form is called you will pass the car_id. your sql will be $sql = "select price from cars where car_id = '$car_id'"; $result = mysql_query($sql); $car_price = mysql_result($result,0); //or //$car_price = mysql_fetch_row($result); I hope this helps. --- Raymond_Lilleødegård <[EMAIL PROTECTED]> wrote: > mysql table is set up like this: > > ------------------------------------------ > bmw | ford | mercedes | > ------------------------------------------ > 100 | 50 | 120 | > > > It is just a very simple one. > > > > ----- Original Message ----- > From: "Jeff Sheltren" <[EMAIL PROTECTED]> > To: "Raymond Lilleodegard" <[EMAIL PROTECTED]>; > <[EMAIL PROTECTED]> > Sent: Friday, January 25, 2002 8:00 PM > Subject: Re: [PHP] dynamic variables in sq?l > > > > Can you show how your mysql table is set up? Otherwise > I am not quite > sure > > what you are trying to do with your SQL statement. > > > > Jeff > > > > > 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; > > > > > > > > > > > > -- > PHP General 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] > ===== Mehmet Erisen http://www.erisen.com __________________________________________________ Do You Yahoo!? Great stuff seeking new owners in Yahoo! Auctions! http://auctions.yahoo.com -- PHP General 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]