limit to first 6 records not working with order by rand()

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 12, 2011   (RSS)

By zaba - July 12, 2011

Hi I have a revolving news set on a home page (a jquery slider). I wanted it to grab the first 6 records in the news database and then push them randomly on the home page. However everything works except it is not pulling in the first 6 records and then delivering randomly it is pulling in a random 6 records from all those available. Heres the code.
is there anything I can do here?

list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'allowSearch' => '0',
'limit' => '6',
'orderBy' => 'RAND()',
));

Re: [Jason] limit to first 6 records not working with order by rand()

By zaba - July 12, 2011

Do you have to put in an orderby clause if you are using the same order as the editor?

Re: [zaba] limit to first 6 records not working with order by rand()

By Jason - July 12, 2011

Hi,

orderBy is optional, so you don't have to include it if you just want to use the the ordering that's in the editor.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] limit to first 6 records not working with order by rand()

By zaba - July 12, 2011

Thanks,
works perfectly!