Re: [gkornbluth] If statement
Sorry...not thinking.
Here is my main page: [/#000000][url "http://www.interactivetools.com/forum/forum.cgi?url=http%3A%2F%2Fsite471.mysite4now.com%2Fcharlottepar%2Ftest%2Fmarketplace%2Findex.php"]http://site471.mysite4now.com/charlottepar/test/marketplace/index.php[/#003366][/url] (Chris orginally helped me with this coding, this page works great)[/#000000]
Code:[/#000000]
<?php
require_once "my hosting information";
list($categoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
));[/#000000]
list($marketplaceRecords, $marketplaceMetaData) = getRecords(array(
'tableName' => 'marketplace',
));[/#000000]
list($marketplace_couponsRecords, $marketplace_couponsMetaData) = getRecords(array(
'tableName' => 'marketplace_coupons',
));[/#000000]
list($marketplace_classifiedsRecords, $marketplace_classifiedsMetaData) = getRecords(array(
'tableName' => 'marketplace_classifieds',
));[/#000000]
// a collection of our records
$recordSets = array(
'marketplace' => $marketplaceRecords,
'coupon' => $marketplace_couponsRecords,
'classified' => $marketplace_classifiedsRecords,
);
// index item records in recordSets by their titles
$rowsByTitle = array();
//foreach ( $recordSets as $recordSetName => &$records ) {
foreach ( array_keys( $recordSets ) as $recordSetName ) {
$records =& $recordSets[$recordSetName];
//foreach ( $records as &$record ) {
foreach ( array_keys($records) as $key ) {
$record =& $records[$key];
// skip processing records without a title
if ( strlen($record['title']) === 0 ) { continue; }
// lookup an existing row by this record's title or create a new one
if ( !array_key_exists($record['title'], $rowsByTitle) ) {
$rowsByTitle[ $record['title'] ] = array();
$rowsByTitle[ $record['title'] ][ 'title' ] =& $record['title'];
$rowsByTitle[ $record['title'] ][ '_link' ] =& $record['_link'];
$rowsByTitle[ $record['title'] ][ 'cats' ] = array();
}
$row =& $rowsByTitle[ $record['title'] ];
// add this record's cats to the row's existing cats
if ( $record['cats'] !== "" ) {
$recordCats = explode("\t", trim($record['cats'], "\t"));
$row['cats'] = array_unique(array_merge( $row['cats'], $recordCats ));
}
// create row-to-record reference keyed on recordSetName
$row[ $recordSetName ] =& $record;
}
}
// index categoryRecords by name
$categoryRecordsByTitle = array();
//foreach ($categoryRecords as &$category) {
foreach ( array_keys($categoryRecords) as $key ) {
$category =& $categoryRecords[$key];
$category['rows'] = array();
$categoryRecordsByTitle[ $category['name'] ] =& $category;
}
// insert rows into categories
//foreach ( $rowsByTitle as &$row ) {
foreach ( array_keys($rowsByTitle) as $rowTitle ) {
$row =& $rowsByTitle[$rowTitle];
//foreach ( $row['cats'] as &$categoryName ) {
foreach ( array_keys($row['cats']) as $index ) {
$categoryName =& $row['cats'][$index];
$categoryRecordsByTitle[ $categoryName ][ 'rows' ][] =& $row;
}
}
// strip categories with no rows
function testCategoryHasRows($category) {
return (count($category['rows']) > 0);
}
$nonEmptyCategories = array_filter($categoryRecordsByTitle, 'testCategoryHasRows');[/#000000]
?>[/#000000][/#000000]
[/#000000]<?php //foreach ($nonEmptyCategories as $category): ?>
<?php foreach ( array_keys($nonEmptyCategories) as $categoryKey ): ?>
<?php $category =& $nonEmptyCategories[$categoryKey]; ?>
<?php echo $category['name'] ?>
<?php //foreach ($category['rows'] as $row): ?>
<?php foreach ( array_keys($category['rows']) as $rowIndex ): ?>
<?php $row =& $category['rows'][$rowIndex]; ?>
<a href="<?php echo $row['_link']; ?>"><?php echo $row['title'] ?></a>
<?php if (array_key_exists('marketplace', $row) && $row['marketplace']['featured_ad']): ?><img src="../images/check.png" width="27" height="23" /><?php endif ?>
<?php if (array_key_exists('classified', $row) && $row['classified']['featured_classified']): ?><img src="../images/check.png" width="27" height="23" /><?php endif ?>
<?php if (array_key_exists('coupon', $row) && $row['coupon']['featured_coupon']): ?><img src="../images/check.png" width="27" height="23" /><?php endif ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php $mergedArray = array_merge_recursive($marketplaceRecords, $marketplace_couponsRecords, $marketplace_classifiedsRecords); ?>
<?php if (!$mergedArray): ?>No records were found!<br />
<?php endif ?>
[/#000000]
Here is my details page: [/#000000][url "http://www.interactivetools.com/forum/forum.cgi?url=http%3A%2F%2Fsite471.mysite4now.com%2Fcharlottepar%2Ftest%2Fmarketplace%2Fdetailsfa.php"]http://site471.mysite4now.com/charlottepar/test/marketplace/detailsfa.php[/#003366][/url] (this is the page I am having the trouble) [/#000000]
<?php
require_once "my hosting information";
list($marketplaceRecords, $marketplaceMetaData) = getRecords(array(
'tableName' => 'marketplace',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$marketplaceRecord = @$marketplaceRecords[0]; // get first record
list($marketplace_couponsRecords, $marketplace_couponsMetaData) = getRecords(array(
'tableName' => 'marketplace_coupons',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$marketplace_couponsRecord = @$marketplace_couponsRecords[0]; // get first record
list($marketplace_classifiedsRecords, $marketplace_classifiedsMetaData) = getRecords(array(
'tableName' => 'marketplace_classifieds',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$marketplace_classifiedsRecord = @$marketplace_classifiedsRecords[0]; // get first record[/#000000]
list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category',
'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
'categoryFormat' => 'showall', // showall, onelevel, twolevel
));
?>[/#000000]
[/#000000]
<a href="#"><?php echo $marketplaceRecord['title'] ?></a>
[/#000000]
<?php if ($marketplaceRecord['featured_ad']): ?><?php echo $marketplaceRecord['feat'] ?><br /><?php endif ?>
<?php if ($marketplace_couponsRecord['featured_coupon']): ?>
Expires:</span> <?php echo $marketplace_couponsRecord['couponexpiration_date'] ?><br /><br>
<?php echo $marketplace_couponsRecord['coucode'] ?><br /><?php endif ?>
[/#000000][/#000000]
<?php if ($marketplace_classifiedsRecord['featured_classified']): ?><?php echo $marketplace_classifiedsRecord['content'] ?><br /><?php endif ?>
<?php if (!$marketplaceRecords): ?>No records were found!<br/>
<?php endif ?>[/#000000]
[/#000000]