rajmohan Posted October 4, 2006 Share Posted October 4, 2006 I am having 10 images in one table now i want to display the image randomly......that is 1 2 34 means after refreshing my page it should change like this3412 then shuffle if i refresh my page please help me Link to comment https://forums.phpfreaks.com/topic/22959-displaying-a-image-in-random/ Share on other sites More sharing options...
ponsho Posted October 4, 2006 Share Posted October 4, 2006 Just use the shuffle function.[code]$array = Array("image1.jpg","image2.jpg","image3.jpg","image4.jpg","image5.jpg");shuffle($array);[/code] Link to comment https://forums.phpfreaks.com/topic/22959-displaying-a-image-in-random/#findComment-103609 Share on other sites More sharing options...
rajmohan Posted October 4, 2006 Author Share Posted October 4, 2006 the no. of images may be countlessThen Link to comment https://forums.phpfreaks.com/topic/22959-displaying-a-image-in-random/#findComment-103613 Share on other sites More sharing options...
ponsho Posted October 4, 2006 Share Posted October 4, 2006 Just get the table rows into an array.[code]$sql = "SELECT images_column FROM your_table";$result = mysql_query($sql);while($data = mysql_fetch_array($result))$images_arr[] = $data["images_column"];shuffle($images_arr);[/code] Link to comment https://forums.phpfreaks.com/topic/22959-displaying-a-image-in-random/#findComment-103615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.