Re: [PHP] dynamic variables in sq?l

2002-01-25 Thread Mehmet Kamil ERISEN

With my respects to your design may I suggest the
following:

1- Table:
CARS
car_id car_name active_flag price
1  BMWY  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 "";
while (list($car_id,$car_name)=mysql_fetch_array($result))
{
 echo "$carname";
   }
echo "";


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]




Re: [PHP] dynamic variables in sq?l

2002-01-25 Thread Raymond Lilleødegård

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]




Re: [PHP] dynamic variables in sq?l

2002-01-25 Thread Jeff Sheltren

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]




[PHP] dynamic variables in sq?l

2002-01-25 Thread Raymond Lilleodegard

Hi all!

I have this form with some choices:


Enter how many cars you want:

ford
bmw
mercedes


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 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]