ORDERBY WITH MULTIPLE CRITERIA - Dec 18th, 2022


To display an image carousel on my home page I needed to pull up a limited number of the most recently created records
in a section and then to randomize the resulting records so the images would appear in random order each time the page
was accessed.

After a number of tries, here's what worked for me:

<?php // load records from 'books
$order1= "RAND(),`createdDate` DESC" ;
list(
$booksRecords, $booksMetaData) = getRecords(array(
'tableName' => 'books',
'loadUploads' => true,
'allowSearch' => true,
'orderBy' => $order1,
'limit' => 75,
));
?>



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service