Searching and Sorting
3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 14, 2014 (RSS)
By esupport - August 13, 2014 - edited: August 14, 2014
Hi
This is our search code.
<form method="POST" action="searchResults.php">
<input name="title,intro_keyword" type="text" value="" size="16">
<input type="submit" name="submit" value="Search">
</form>
It will display all related keywords on the searchResults.php page.
I have no idea how the search results sorting .
What is the sorting rule?
Is it possible to change?
Thanks a lot!
Jac
Hi Jac,
I guess you're using the getRecords function to retrieve your results? If so you can add an orderBy variable to it's array to decide what order the results are displayed in:
// load records from 'blog'
list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'loadUploads' => true,
'allowSearch' => true,
'orderBy' => "title, content DESC"
));
The orderBy variable should contain a MySQL ORDER BY string. You can read about it here:
http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html
By default the function will order the results by what you have set in the sections settings. (See attached screen shot).
Thanks,
Greg
PHP Programmer - interactivetools.com
By esupport - August 14, 2014
Hi Greg
Always get nice help from you.
It is a really useful information.
Thank you!
Jac