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 Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.