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? Link to comment https://forums.phpfreaks.com/topic/93735-shuffle-array-taken-from-mysql/ 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. Link to comment https://forums.phpfreaks.com/topic/93735-shuffle-array-taken-from-mysql/#findComment-480318 Share on other sites More sharing options...
Baabu Posted February 29, 2008 Author Share Posted February 29, 2008 thx mate Link to comment https://forums.phpfreaks.com/topic/93735-shuffle-array-taken-from-mysql/#findComment-480326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.