Jump to content

Variable in mysql


simpso

Recommended Posts

What trq is saying is write it like this:

 

$idno = "1";
$cost = "select price from products where Id = $idno";

 

If you place a

 

echo $cost;

 

beneath that it will display "select price where id=1"

 

But not sure what you're trying to do with this. Seems like you're trying to do a MySql query. Only reason I can think of for a statement like that. You're a long way from doing that with the above.

Link to comment
https://forums.phpfreaks.com/topic/272811-variable-in-mysql/#findComment-1404034
Share on other sites

To elaborate:

 

$something = 'hello';
$single_quote_string = 'Look at this: $something';
$double_quote_string = "Look at this: $something";

echo $single_quote_string . '<br />' . $double_quote_string;

 

The output will be as follows:

Look at this: $something
Look at this: hello

Link to comment
https://forums.phpfreaks.com/topic/272811-variable-in-mysql/#findComment-1404092
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.