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

Re: [chris] Ordering by Multiple Value Lists

By studio-a - December 17, 2010

Hi Chris,

Thanks for your input and time. We will create a test page removing all of the Code Jason recommended and try this new code.

For the sake of this tutorial thread, it appears your approach is completely different than the code Jason began the thread topic with, is this correct?

Based on your code, the direction for this solution would be to create a special MySQL query when pulling the records (hence grouping the items which have the same category). Whereas, Jason's method was to use arrays within the PHP to group the items with the same category, is this correct?

We will let you know our efforts with implementing the code and to assist the thread's topic.

Thanks again for your help. You guys really do supply great support!

studio-a