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>"; } ?> Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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>"; } ?> 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.