$count_sql = "select * from portfolio";
mysql_num_rows($cresult);
this will load every thing you have to the memery.
i got a better way to doing this let the mysql return the number without loading to memery then calulate the total
change into:
$sql = "select count(ID) as num from portfolio";
$num = mysql_result($sql 0,'num');
try this.. much much more faster especically you have a huge database like 100K rows and this will save @!#$ load of memery..
but it seems doesn't work with Where statement on my machines......
vincent wrote:
I'm not quite sure what you want to do with
order by $random limit 3
because you previously defined $random to be a value,
it's like ordering your results by 1 or by 3 or by 11
This does not order the results in a random way.
In MySQL 3.23 you could user "ORDER by Rand()"
Or you could create a semi-random set of images
by generating a number between 1 and (num_rows-2),
and using the offset command in mysql to start fetching results from 1-3 or 4-6 or 9-11
$random=(a_number_between_1_and_9)
select * from table where bla limit $random,3