Question for Where statement

6 posts by 3 authors in: Forums > CMS Builder
Last Post: November 11, 2009   (RSS)

By avrom - November 7, 2009

Hi guys,

I need to sort information from 2 specific records in a list section called properties:

list($propertiesRecords, $propertiesMetaData) = getRecords(array(
'tableName' => 'properties',
));


The 2 records to display are based on two values from a detail viewer.

$home_pageRecord['property_1']
and
$home_pageRecord['property_2']

How would I insert these two values property_1 and property_2 into the where clause for the properties viewer on this page ?

Thanks !
Avrom

Re: [virgodesign] Question for Where statement

By Damon - November 11, 2009

Hi Avrom,

Let's review by email what the published content output generated should be. Then we can figure out the code to get there. :)
Cheers,
Damon Edis - interactivetools.com

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

Re: [Dave] Question for Where statement

By avrom - November 11, 2009

Hi Dave,

Thanks, but I get this error for the recordNum variable:

Notice: Undefined variable: homepageRecord in ***/index.php on line 22 MySQL Error: Unknown column 'recordNum' in 'where clause'

Cheers
Avrom

Re: [virgodesign] Question for Where statement

By Dave - November 11, 2009

Try changing recordNum to num. I updated my original post to show that.

If there's still errors attach the viewer file and I'll take a look.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [virgodesign] Question for Where statement

By avrom - November 11, 2009

Hi Dave,

OK that's perfect !! :)) I made a small edit to preserve the coding in my featured_properties module. I'm sure these can now be combined into one query, AND statement in Where clause with limit => 2, but not quite sure how to do that:

// load first featured property
list($featuredProperties, $propertiesMetaData) = getRecords(array(
'tableName' => 'properties',
'where' => " num = '" .mysql_real_escape_string($home_pageRecord['property_1']). "' ",
'allowSearch' => false,
));
$featuredProperty[0] = @$featuredProperties[0]; // get first record

// load second featured property
list($featuredProperties, $propertiesMetaData) = getRecords(array(
'tableName' => 'properties',
'where' => " num = '" .mysql_real_escape_string($home_pageRecord['property_2']). "' ",
'allowSearch' => false,
));
$featuredProperty[1] = @$featuredProperties[0]; // get second record

OK, thanks again, and please invoice for the time on this ^^ :))

Cheers
Avrom