Question for Where statement

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

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: [virgodesign] Question for Where statement

By Dave - November 11, 2009 - edited: November 11, 2009

Hi Avrom,

I've reviewed the email details you sent in. I think the easiest way to do this is with 3 queries as follows:

// load featured property numbers
list($home_pageRecords, $home_pageMetaData) = getRecords(array(
'tableName' => 'home_page',
'allowSearch' => false,
));
$homepageRecord = @$home_pageRecords[0]; // get first record

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

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


And you'd display their values like this:
Address: <?php echo $secondProperty['address'] ?><br/>

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

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