I am hoping this can be done easily, I am new at PHP, but have a background in the"old" basic programming so I understand the basics.
I need to limit the rows of the outputted HTML table to three rows. I am hoping that will allow the Rand() function to work "more randomly", than putting a limit in the query statement.
I have put the php code that I am currently working with. It limits the columns to five, but I would like to limit the rows to three. Also if someone knows of a way to help the Rand() function not repeat entries as often that would be great. The table I am working with has over 400 entries, but when I use Limit 15 with the Rand() there are alot of repeats within a couple refreshes of the page.
srand((double) microtime() * 1000000);
$result = mysql_query("SELECT * FROM Table ORDER BY rand()");
$query = mysql_query("SELECT imglink, link FROM Table");
echo "<table cellpadding=5>";
$row_count = 0;
$columns = 5;
$row = mysql_fetch_array($query, MYSQL_ASSOC);
while($row = mysql_fetch_array($result)){
if ($row_count == $columns) {
echo "</tr><tr>";
$row_count = 0;
}
echo "<td background='images/back1.jpg' align=center><a href='{$row['link']}'target=_blank><img src='{$row['imglink']}'width=160 height=120 border='0' /></a></td>";
$row_count++;
}
?>
Thank you in advance for your help.
Stacey