Re: [dccreatives] If then statement help
Hi,
Okay, I think I see what you're trying to do. The first problem I'm seeing with the page is all of your getRecords calls is using the "whereRecordNumInUrl()" function. That means if you're looking at item record 2, your retrieving the second record for all your other sections (distribution, brands, and downloads) as well. Chances are these records will not match up the way you want them to.
What is the name of the field in "downloads" that you associate with the "download_id" in "items"? In this example, we'll assume that you're using the "num" field in downloads to associate with the "download_id" field in items.
In that case, you would want to do your selection like this:
list($itemsRecords, $itemsMetaData) = getRecords(array(
'tableName' => 'items',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
// show error message if no matching record is found
if (!$itemsRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
$itemsRecord = $itemsRecords[0]; // get first record
list($downloadsRecords, $downloadsMetaData) = getRecords(array(
'tableName' => 'downloads',
'where' => "num = '".mysql_escape($itemsRecord['download_id'])."'",
'limit' => '1',
));
if ($downloadsRecord) {
$downloadsRecord = @$downloadsRecords[0]; // get first record
}
else {
$downloadsRecord = array();
}
This code means that downloadsRecord would only have a value if the download_id of the selected items record has a record in the downloads section. That way when deciding whether or not to display the downloads link is whether or not downloads['bim_files'] has a value:
<?php if (@$downloadsRecord['bim_files']): ?>
<li> <a href="http://www.axislighting.com/CMS/downloadsDetail-pop-bim.php?<?php echo $itemsRecord['download_id'] ?>" target="_blank" rel="gb_page_center[700, 480]">BIM Files</a></li>
<?php endif ?>
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/