contra10 Posted March 20, 2009 Share Posted March 20, 2009 i'm trying to show 6 different random pics but i get 6 of the same image being echoed <?php $resultalumni1 = "SELECT * FROM users WHERE image = 'true' ORDER BY RAND() LIMIT 6"; $result = mysql_query($resultalumni1) or die(mysql_error()); while ($rowalumni1 = mysql_fetch_array($result)){ $picid1 = "{$rowalumni1['id']}"; echo "<table border='0' width='400'>"; echo "<tr>"; echo "<td WIDTH='33%' height='100' align='center'><img src='http://www.test.com/image/imagereplace.php?id=$picid1'></td></a>"; echo "<td WIDTH='33%' height='100' align='center'><img src='http://www.test.com/image/imagereplace.php?id=$picid1'></td></a>"; echo "<td WIDTH='33%' height='100' align='center'><img src='http://www.test.com/image/imagereplace.php?id=$picid1'></td></a>"; echo "</tr>"; echo "<tr>"; echo "<td WIDTH='33%' height='100' align='center'><img src='http://www.test.com/image/imagereplace.php?id=$picid1'></td></a>"; echo "<td WIDTH='33%' height='100' align='center'><img src='http://www.test.com/image/imagereplace.php?id=$picid1'></td></a>"; echo "<td WIDTH='33%' height='100' align='center'><img src='http://www.test.com/image/imagereplace.php?id=$picid1'></td></a>"; echo "</tr>"; echo "</table>"; } ?> Link to comment https://forums.phpfreaks.com/topic/150270-simply-rand-getting-me-crazy/ Share on other sites More sharing options...
contra10 Posted March 20, 2009 Author Share Posted March 20, 2009 i'm looking at the code but i can't find prob Link to comment https://forums.phpfreaks.com/topic/150270-simply-rand-getting-me-crazy/#findComment-789158 Share on other sites More sharing options...
ram4nd Posted March 20, 2009 Share Posted March 20, 2009 You have to use while to echo them separately or you just show the first image. You can alsu use [] after variable. Link to comment https://forums.phpfreaks.com/topic/150270-simply-rand-getting-me-crazy/#findComment-789159 Share on other sites More sharing options...
redarrow Posted March 20, 2009 Share Posted March 20, 2009 This will give you 6 random pictures. <?php $resultalumni1 = "SELECT * FROM users WHERE image = 'true' ORDER BY RAND() LIMIT 6"; $result = mysql_query($resultalumni1) or die(mysql_error()); while ($rowalumni1 = mysql_fetch_array($result)){ $picid1 = "{$rowalumni1['id']}"; echo "<table border='0' width='400'>"; echo "<tr>"; echo "<td WIDTH='33%' height='100' align='center'><img src='http://www.test.com/image/imagereplace.php?id=$picid1'></td></a>"; echo "</tr>"; echo "</table>"; } ?> Link to comment https://forums.phpfreaks.com/topic/150270-simply-rand-getting-me-crazy/#findComment-789164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.