lordphate Posted May 12, 2007 Share Posted May 12, 2007 Okay, so this is what i'm trying to do. I want to pull photo_small and art_id out of the database, but i want to pull them at random here's what I have but it's still listing in same order: [code=php:0] function tattoo_slide(){ $sql_query="SELECT art_id, photo_small FROM tatoo_art WHERE approved='1' ORDER BY RAND() LIMIT 1"; $result = $GLOBALS["DB"]->result($sql_query); $tatslide = prepare_photos_array($result); $tatslide["total"] = count($result); $tatslides = array(); $counter = 0; foreach($result as $res){ $tatslide["links"] = "http://tatfactory.com/index.php?page=art§ion=view&art_id=".$res["art_id"]; $tatslide["images"] = $res["photo_small"]; $conveyor .= 'leftrightslide['.$counter.']=\'<a href="'.$tatslide["links"].'"><img src="/photos/'.$tatslide["images"].'" border=0></a>\';'; $counter +=1; }//foreach $GLOBALS["smarty"]->assign("conveyor",$conveyor); } //tattoo_slide [/code] Link to comment https://forums.phpfreaks.com/topic/51017-random-photos/ Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Share Posted May 12, 2007 instead of specifying rand in the SQL, use shuffle on the array retreived. gdlk Link to comment https://forums.phpfreaks.com/topic/51017-random-photos/#findComment-251103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.