[SOLVED]simple sql statement

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

[SOLVED]simple sql statement

Post by pinehead18 »

Ok basically i need to know how to use a var to specify a field in sql.

example $sql = "SELECT * FROM db WHERE $var='$var'";

Thanks
Anthony
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

well, that's exactly how to do it ;)

another way is :

Code: Select all

$var = 'name';
$var2 = 'Bob';
$sql = "SELECT * FROM DB WHERE ".$var." = '".$var2."'";
Last edited by infolock on Sat Jan 17, 2004 6:53 pm, edited 1 time in total.
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

thank you
Post Reply