Here is what i want to use and I was using:
$sql="SELECT * from channel ORDER BY rand() LIMIT 6 ";
$rs = $conn->
Execute($sql);
$channellist = $rs->
getrows();
But this creates errors, the whole site goes blank.
In the server error logs this is the error:
[28-Jul-2013 09:53:37 America/Detroit] PHP Fatal error: Call to a member function getrows() on a non-object in /home/hotspitt/public_html/cache/templates_c/%%C3^C37^C3724EE2%%head1.tpl.php on line 60
Removing line 60 ( $channellist = $rs->getrows();
) makes it work. and also changing it to:
$sql="SELECT * from channel ORDER BY ID desc LIMIT 6 ";
$rs = $conn->
Execute($sql);
$channellist = $rs->
getrows();
makes it work. So I think there is something wrong with the rand function. I can't understand why rand() function is not working.
Please help me out with this.
select * from user_details order by rand() limit 10
working, now problem either your table name or your library used for executing sql