query with two conditions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

query with two conditions

Post by inosent1 »

Code: Select all

$query="select * from ldata where $term_s LIKE '%$term%'";

i want to search based on 2 conditions

eg

Code: Select all

$query="select * from ldata where $term_s LIKE '%$term%' AND WHERE entity='$company'";
but i dont know the precise syntax
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: query with two conditions

Post by twinedev »

You were very close, just get rid of the second "WHERE":

Code: Select all

$query="SELECT * FROM `ldata` WHERE `$term_s` LIKE '%$term%' AND `entity`='$company'";
Post Reply