Thanks -- I am not sure what that is doing. The problem I am trying to solve is that I have a very small database of images (10 now, may grow to as many as 50) and so with a random variable function, it is very likely that visitors will see repeats during a brief visit to my site. I would like for the function to simply call them in order, starting from 1 to the end. I don't mind them having to start at 1 each time they come to my site. Someday, when the database is larger, I can go back to random. How do I get a sequential order? I tried this, but it kept going from row 1 to 2 and then back to one again, in an endless loop:
function getRandomUser()
{
static $row=0;
$connection = mysql_pconnect(SQL_SERVER, SQL_UID, SQL_PWD);
mysql_select_db(SQL_DB, $connection);
$sql = "select * from user where active=1 and inrotation = 1";
$query = mysql_query($sql);
$rows = mysql_num_rows($query);
if ($rows==0)
return Array('id'=>-1, "uid"=>'', "picurl"=>'');
if ($row < $rows)
{ mysql_data_seek($query, $row);
$record = mysql_fetch_array($query);
$row++;
return $record;
}
else
{
$row = 0;
mysql_data_seek($query, $row);
$record = mysql_fetch_array($query);
return $record;
}
}
Thanks again!
Tom Anderson wrote:
$sql = "select *, rand() as randorder from user where active=1 and inrotation = 1 order by randorder";