View Full Version : Database and DW

08-25-2008, 12:55 AM

Im using dreamweaver to build my pages and all. For the database, im using phpmyadmin. what i want to do is to get random data from pool of data in the database. say.. 10 data to be displayed out of 50.

the statement i made were as follow.

"SELECT * FROM sample_exam ORDER BY rand() limit 10 ";

whenever i run this, it shows me an error and the error is this.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 10' at line 1

Does it mean my syntax is wrong? Or is it that my version of phpmyadmin does not support the limit statement or something?

08-25-2008, 03:56 AM
from php sie

$random_rows = array();

$query = mysql_query("SELECT * FROM tablename ORDER BY RAND() LIMIT 10");

while($row = mysql_fetch_array($query))
$random_rows[] = $row;

08-25-2008, 04:03 AM
Now it prompt me with this error.

mysql_fetch_array(): supplied argument is not a valid MySQL result resource...

i dont understand what's the problem.