if else question

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 2, 2012   (RSS)

Re: [Rohwer] if else question

By Jason - May 2, 2012

Hi,

Since "family" is a field name in your newvehicles section, getRecords is automatically adding it to your WHERE clause. To stop this you can use the "allowSearch" => false, option like this:

NOTE: I also changed your query to use the mysql IN clause. It just helps the code be a little easier to read:

$motorcycles = @$_GET['family'];

if($motorcycles == "motorcycle") {

list($newvehiclesRecords, $newvehiclesMetaData) = getRecords(array(
'tableName' => 'newvehicles',
'where' => "active = '1' and newused = 'Used' AND family IN('Cruiser', 'Dirtbike', 'Sportbike', 'Touring','Trikes')" ,
'allowSearch' => false,
'perPage' => $perPage,
'orderBy' => $order,
));
}
else {

list($newvehiclesRecords, $newvehiclesMetaData) = getRecords(array(
'tableName' => 'newvehicles',
'where' => "active = '1' and newused = 'Used'",
'allowSearch' => false,
'perPage' => $perPage,
'orderBy' => $order,
));

}


Give this a try and let me know if this gives you the results you are looking for.

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] if else question

By Rohwer - May 2, 2012 - edited: May 2, 2012

You sir.... rock.

Just had to remove the 'allowSearch' => false, in the else portion.

because this page only has that one exception.

Much appreciated!