Show next record (that matches the criteria)

17 posts by 2 authors in: Forums > CMS Builder
Last Post: September 7, 2009   (RSS)

This line:

$tile_fields = array('floor_tile', 'floor_grout', 'shower_wall_1');

lists the fields that you want looked up in tile_sku. Those fields in your tile_images record will be replaced by records from tile_sku. You'll want to add all your other fields you want looked up too.


So we're speaking the same thing, "tile_images" holds all the images and pulls data from table "tile_details" - what you are calling "tile_sku" above. Now, was there a typo above (the bold bit)? Don't you mean that that line of code is telling the page which fields in "tile_images" table need to be replaced with information from the "tile_details" table?

tile_details table only has 3 fields - tile_sku, tile_dimensions, and category (see attached screenshot) - are they the fields I should be adding up above? It throws an error when I do, so I assume that I should not do that.

Your last part of your post is exactly correct, I want to show "tile_sku" from the "tile_detail" table. I have incorporated the above - no errors, but unfortunately, no labels still.

Thanks again. I have reposted the page again.

Re: [benedict] Show next record (that matches the criteria)

Hi Chris,

Any word on this? Sorry to hassle, but we're due in 24 hours.

Cheers.

Re: [benedict] Show next record (that matches the criteria)

By Chris - September 5, 2009

Hi benedict,

Sorry about that. I should have tested with a list page like you have. Please replace this:

$tile_imagesRecord = @$tile_imagesRecords[0]; // get first record
// show error message if no matching record is found
if (!$tile_imagesRecord) {
print "Record not found!";
exit;
}


with this:

// show error message if no matching record is found
if (!@$tile_imagesRecords[0]) {
print "Record not found!";
exit;
}

// get first record
$tile_imagesRecord =& $tile_imagesRecords[0];


That should work. It does here.
All the best,
Chris
Take a bow, mate. You are a rockstar. Works a treat.

Re: [benedict] Show next record (that matches the criteria)

Hi Chris,

Sorry to do this to you, but there's one last issue. All the tile grout fields are pulling their data from a different table, tile_grouts instead of tile_details. I tried duplicating your code with variations, but I get this error:

Fatal error: Cannot redeclare collectrecordvalues() (previously declared in /home/jglimpse/public_html/national/detail.php:24) in /home/jglimpse/public_html/national/detail.php on line 51

I have reattached. Thanks.
Attachments:

detail_006.php 18K

Thanks Chris - this all works brilliantly. Thanks for all your assistance. For anybody following this post in the future, the site resides at:

http://www.metricontilestudio.com.au

I think adding your function into CMSB is a great idea - it seems like just a more natural method for laying out the database with raw data tables being pulled into a central table that the user manages. About 60% of all sites i do with CMSB use this in some way and I think that will be 100% now I have these tools gained here.