Retrieve articles from array of category ids [duplicate]
I have an array of category i开发者_StackOverflowds and want to retrieve articles from my mysql database with these category ids. What is the best method for this?
mysql_query('SELECT * FROM articles WHERE category_id IN (\''.implode('\'',array_map('mysql_real_escape_string',$categories)).'\')');
Specify how articles are joined to categories if this is not how your db/table setup.
Look here:
- I have an array of integers, how do I use each one in a mysql query (in php)?
for a safe, parameter-based approach and code sample.
精彩评论