Current location: Hot Scripts Forums » Programming Languages » PHP » search MySQL field for any item from array

search MySQL field for any item from array

 
Prev Previous Post   Next Post Next
  #1  
Old 06-23-09, 01:36 PM
m_abdelfattah m_abdelfattah is offline
Newbie Coder
 
Join Date: Sep 2004
Location: Alexandria, Egypt.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
search MySQL field for any item from array

Now, I've MySQL field called `catgegory_ids`, if one row contains (1,5,23,45) . how can I make a search if any of these categories (1,5) are found ??

I thought of making the following:
PHP Code:
$category_ids = array(1,2,5,10);
foreach(
$category_ids AS $category_id) {
$query .= "OR `category_ids` LIKE `%" $category_id "%' ";

But I feel it's stupid way !
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Superfish jquery menu problems with modification transcend2005 CSS 2 03-25-09 02:30 AM
display mysql data in columns? todayscoffee PHP 4 03-11-09 11:05 PM
Help making a certain field into a hyperlink from an echoed MySQL table cynebald PHP 5 05-11-06 11:20 PM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 08:59 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)