SitePoint Sponsor |
|
User Tag List
Results 1 to 1 of 1
-
Jul 4, 2001, 13:48 #1
- Join Date
- Jun 2001
- Location
- Indianapolis, IN
- Posts
- 12
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Php - (Random Photo) using random function
I am trying to make a random function generator for php... that will show a different picture everytime.. instead of like showing 2 different ones, and then picking one it has already shown. Meaning pretty much go through all the pictures before circling back through the others, now I don't want it to go down the list.. like pic1, pic2, but I Don't want it to show certain pictures over and over
here is some of the code I have.. it works for randomizing, but I need to add some variables or something that will keep it from showing over and over... anyone good with this and can help out?!
PHP Code:function getRandomUser()
{
srand((double)microtime()*1000000);
$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('userid'=>-1, "username"=>'', "picurl"=>'');
$row = rand(0, $rows - 1);
mysql_data_seek($query, $row);
$record = mysql_fetch_array($query);
return $record;
}
so can anyone help out in this department?!@
thanks
BradCBradC
Bookmarks