0

I have an array in which 7 Id exist . I want to Fetch Record Of that ids In AND Operator My Query Is this

my array that Hold & ids is this $type_id

$query =("SELECT * FROM property Where Id ='".$id."' AND property_type='".$type_id."' ");

How This Query Execute That it Got all Records Of type_id

 if Print_r($type-id);

Then result is

1,7,5,8,5,4,9

Any Suggetion And Help will Be appreciated

1
  • On a side note, please escape the variables in your query if you aren't already doing so. Commented Dec 27, 2011 at 12:49

2 Answers 2

1
$type-id 

is wrong variable in php so your result goes wrong use $type_id instead

Sign up to request clarification or add additional context in comments.

2 Comments

sorry i mean variable, - is operator in php so its not allowed in variable name...
$type-id is an invalid identifier, the - character is not allowed.
0

Not sure if I'm completely clear what you're asking but I think you need the IN operator, something like this:

"SELECT * FROM property 
 Where Id ='".$id."' AND 
 property_type IN (".implode(',',$type_id).") "

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.