Baabu Posted February 29, 2008 Share Posted February 29, 2008 <?php mysql_connect("localhost","test","pass") or die ('Unable to Connect'); mysql_select_db("test")or die('Unable to select');; $query="select * from images"; $result=mysql_query($query) or die ("Error in Query .".mysql_error()); shuffle($result); while($row=mysql_fetch_array($result)) { ?> <img src="<?php echo $row['path'];?>"> <?php echo "<br>"; } ?> well this code takes the path from mysql image table and then displays the image everything is working fine i just want to know how can i make these images to be random like they are displayed as in the order they are stored i want to change it each time mysql returns the paths in $result they should be shuffled?? any suggestions? Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted February 29, 2008 Share Posted February 29, 2008 ORDER BY RAND() is probably what you're looking for. $query="select * from images ORDER BY RAND()"; Remove the shuffle() too. Quote Link to comment Share on other sites More sharing options...
Baabu Posted February 29, 2008 Author Share Posted February 29, 2008 thx mate 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.