Only first record found in Multi Record section

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 15, 2011   (RSS)

I have a Multi Record section that has an index page listing articles' headlines - http://masselsm.temporaryurl.biz/about-boating.php - which link to individual articles. The index only seems to find the first article - http://masselsm.temporaryurl.biz/about-boatingDetail.php?Is-boating-affordable-1 - with the subsequent articles I get a "Record not found" error message; e.g. http://masselsm.temporaryurl.biz/about-boatingDetail.php?Tips-from-the-toolbox-2.

Any suggestions, please?

Here's the code that loads the records. I've included the full code, which includes other elements that are loaded on this page, just in case there's some sort of conflict here.

======

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/masselsm/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$articlesRecord = @$articlesRecords[0]; // get first record


// show error message if no matching record is found
if (!$articlesRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}


// load records
list($panel_logosRecords, $panel_logosMetaData) = getRecords(array(
'tableName' => 'panel_logos',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$panel_logosRecord = @$panel_logosRecords[0]; // get first record

// show error message if no matching record is found
if (!$panel_logosRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

// load records
list($panel_snowmobile_logosRecords, $panel_snowmobile_logosMetaData) = getRecords(array(
'tableName' => 'panel_snowmobile_logos',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$panel_snowmobile_logosRecord = @$panel_snowmobile_logosRecords[0]; // get first record

// show error message if no matching record is found
if (!$panel_snowmobile_logosRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>

======

Thanks!
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [Jason] Only first record found in Multi Record section

Hi, Jason.

I've removed all of the occurrences of 'where' => whereRecordNumberInUrl(1), and now when you click on any headline link here - http://masselsm.temporaryurl.biz/about-boating.php - it displays the same content, even though the URL shown in the browser indicates it's a different page. e.g. http://masselsm.temporaryurl.biz/about-boatingDetail.php?Is-boating-affordable-1 and http://masselsm.temporaryurl.biz/about-boatingDetail.php?Tips-from-the-toolbox-2.

Any idea why this might be, please?

======

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/masselsm/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'limit' => '1',
));
$articlesRecord = @$articlesRecords[0]; // get first record

// load records
list($panel_logosRecords, $panel_logosMetaData) = getRecords(array(
'tableName' => 'panel_logos',
'limit' => '1',
));
$panel_logosRecord = @$panel_logosRecords[0]; // get first record

// load records
list($panel_snowmobile_logosRecords, $panel_snowmobile_logosMetaData) = getRecords(array(
'tableName' => 'panel_snowmobile_logos',
'limit' => '1',
));
$panel_snowmobile_logosRecord = @$panel_snowmobile_logosRecords[0]; // get first record

?>
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Attachments:

about-boatingdetail.php 10K

Re: [NigelGordijk] Only first record found in Multi Record section

By Jason - February 15, 2011

Hi Nigel,

You do want to use the where clause for your multirecord section, just not the single record sections. Try this:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/masselsm/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$articlesRecord = @$articlesRecords[0]; // get first record

// load records
list($panel_logosRecords, $panel_logosMetaData) = getRecords(array(
'tableName' => 'panel_logos',
'limit' => '1',
));
$panel_logosRecord = @$panel_logosRecords[0]; // get first record

// load records
list($panel_snowmobile_logosRecords, $panel_snowmobile_logosMetaData) = getRecords(array(
'tableName' => 'panel_snowmobile_logos',
'limit' => '1',
));
$panel_snowmobile_logosRecord = @$panel_snowmobile_logosRecords[0]; // get first record

?>


Hope this helps
---------------------------------------------------
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] Only first record found in Multi Record section

Perfect! Many thanks for your help.
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net