Hi!
Sorry about the daily questions, but this project I am working on is proving tricky [crazy]
I am merging arrays to output two separate tables (which have identical fields) on the same page as one list.
I would like to be able to limit it to 10 per page, but whatever I try it still outputs everything on the one page.
Here is how I do it:
// load records
list($national_newsRecords, $national_sachs_newsMetaData) = getRecords(array(
'tableName' => 'national_sachs_news',
'allowSearch' => '0',
'perPage' => '10',
));
// Tip: $dealer_newsRecords, $dealer_newsMetaData are the array names!
list($dealer_newsRecords, $dealer_newsMetaData) = getRecords(array(
'tableName' => $final,
'allowSearch' => '0',
'perPage' => '10',
));
// put all the records in one list
$allRecords = array_merge( $dealer_newsRecords, $national_newsRecords );
$allMetaData = array_merge( $dealer_newsMetaData, $national_newsMetaData );
// sort them by date
function createdDateCompareFunction($a, $b) { return -strcmp($a['createdDate'], $b['createdDate']); }
usort($allRecords, 'createdDateCompareFunction');
?>
Then to display I use:
<?php if ($allMetaData['invalidPageNum']): ?>
Results page '<?php echo $allMetaData['page']?>' not found, <a href="<?php echo $allMetaData['firstPageLink'] ?>">start over >></a>.<br/><br/>
<?php elseif (!$allMetaData): ?>
No records were found!<br/><br/>
<?php endif ?>
<?php foreach ($allRecords as $record): ?>
<div class="post" id="<?php echo $record['identify'] ?>-<?php echo $record['num'] ?>">
<h1><?php echo $record['title'] ?></h1>
<h6><?php echo $record['description'] ?></h6>
<div class="info"><?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?></div>
<p>
<?php foreach ($record['main_news_image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a><br/>
<?php else: ?>
<?php endif ?>
<?php endforeach ?>
</p>
<a href="<?php echo $record['_link'] ?>" class="button-small">Read More</a></p>
</div>
<br/><br/><br/><br/>
<?php endforeach ?>
<div class="pagination">
<ul class="page-numbers">
<li>
<span class="page-numbers current">Page: <?php echo $national_sachs_newsMetaData['page'] ?> of <?php echo $allMetaData['totalPages'] ?></span>
</li>
<li>
<?php if ($allMetaData['prevPage']): ?>
<a href="<?php echo $allMetaData['prevPageLink'] ?>" class="next page-numbers"><< prev</a>
<?php else: ?>
<?php endif ?>
</li>
<li>
<?php if ($allMetaData['nextPage']): ?>
<a href="<?php echo $allMetaData['nextPageLink'] ?>" class="next page-numbers">next >></a>
<?php else: ?>
<?php endif ?>
</li>
</ul>
</div>
Where am I going wrong?
Thanks!
Paul