Small where clause issue

12 posts by 2 authors in: Forums > CMS Builder
Last Post: April 19, 2010   (RSS)

By Jason - April 19, 2010

Hi,

We're going to need to change our code a bit. Try this code for getting the records:

<?php

list($catsRecords,$catsMetaData)=getRecords(array(
'tableName'=>'category',
'where'=>"title='ATP' or title='Australian Open'",
'allowSearch'=>0,
));

$count=0;
foreach($catsRecords as $cats){
if($count==0){
$catlist="category LIKE ";
$count++;
}
else
$catlist.=" AND category LIKE ";

$catlist.="'%\t".$cats['num']."\t%'";
}


list($catRecords,$catMetaData)=getRecords(array(
'tableName'=>'fpvideo',
'where'=>$catlist,
'allowSearch'=>0,
));
?>


Now, you may need to change this depending on exactly what you want to return. If you want to get all of the records whose category is ATP AND Australian Open, then you can leave this code as it is. If you want to get the records whose category is ATP OR Australian open, you need to change this one line:

$catlist.=" OR category LIKE ";

Give that a try and let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/