Re: [Dan Maitland] Pulling records from another table.
Ok so I got it to work again on one viewer but even with the exact same code I cant seem to get it to work on the original building page. The error even got longer it now reads:
Notice: Undefined variable: suitesRecord in /home/davgol20/goldcastleholdings.com/property.php on line 23 Notice: Undefined offset: 0 in /home/davgol20/goldcastleholdings.com/property.php on line 26
Code at the top of my page:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/davgol20/goldcastleholdings.com/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
list($buildingsRecords, $buildingsMetaData) = getRecords(array(
'tableName' => 'buildings',
'limit' => '0',
));
$buildingsRecord = $buildingsRecords[0];
list($suitesRecords, $suitesMetaData) = getRecords(array(
'tableName' => 'suites',
'where' => 'building = "' . mysql_escape($buildingsRecord['building_name']) . '"',
));
list($agentsRecords, $agentsMetaData) = getRecords(array(
'tableName' => 'agents',
'where' => mysql_escapef('num = ?', $suitesRecord['agent']),
'limit' => 1,
));
$agentsRecord = $agentsRecords[0];
?>
The code in the body:
<?php foreach ($agentsRecords as $record): ?>
<?php echo $record['name'] ?>
<br />
T: <?php echo $record['phone'] ?> | F: <?php echo $record['fax'] ?> | E: <a href="mailto:<?php echo $record['email'] ?>"><?php echo $record['email'] ?></a>
<?php endforeach ?>