Ordering by Multiple Value Lists

23 posts by 4 authors in: Forums > CMS Builder
Last Post: December 17, 2010   (RSS)

By Chris - December 16, 2010 - edited: December 16, 2010

Hi studio-a,

Would something like this work for you?

<?php
list($attractions_categoriesRecords, $attractions_categoriesMetaData) = getRecords(array(
'tableName' => 'attractions_categories',
'perPage' => '3',
));
?>

...

<?php foreach ($attractions_categoriesRecords as $category): ?>

<h2>Category: <?php echo htmlspecialchars($category['title']); ?></h2>

<?php
list($local_attractionsRecords, ) = getRecords(array(
'tableName' => 'attractions',
'where' => "category LIKE '%\t" . mysql_escape($category['title']) . "\t%'"
));
?>

<ul>
<?php foreach ($local_attractionsRecords as $attraction): ?>

<li><?php echo htmlspecialchars($attraction['name']); ?></li>

<?php endforeach ?>
</ul>

<?php endforeach ?>

<!-- add pagination links using $attractions_categoriesMetaData -->


Please let me know if you have any questions.
All the best,
Chris

By Chris - December 17, 2010 - edited: December 17, 2010

Hi studio-a,

Yes, this approach is completely different. The method that Jason suggested is more efficient when displaying all the categories on one page.

Please let me know if you have any questions.
All the best,
Chris