Thanks for everyone's help with this. I found what the problem was:
The <table> and <tr> tags need to be outside the loop. The <td></td> tags are inside the loop where your displayed info goes. The loop counts each item, then if it reaches your predefined count it puts</tr><tr> to start another row and resets the count to 0. If not, then after the loop you close off the row with </tr></table>.
My problem was not knowing how to determine where the counter should be placed within my code, and how to use that to start another row.
I'm sure that this isn't the only way to achieve this, but it is one way that works.
Sometimes when you are new to programming and people try to help by giving you a snippet of code without really explaining where it goes and why, it gets confusing. I had several people respond by giving me a code snippet, but I couldn't figure out how to use it correctly.
See below for working code. The number of items to display per row can be easily changed to any number.
Again, it is a very simple thing, but if you have no clue how to use it correctly it can be very frustrating.
<html>
<head>
<title>PHOTO GALLERY</title>
</head>
<body bgcolor=black>
<font color=white>
<?php
// Connects to your Database
mysql_connect("localhost", "user", "pw") or die(mysql_error()) ;
mysql_select_db("dbase") or die(mysql_error()) ;
Echo "<center><h1>Visitor Photo Gallery</h1></center><br><hr>";
//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM visitorpics") or die(mysql_error());
?>
<table align=center border=0 cellpadding=5 cellspacing=5>
<tr>
<?php
$x=0;
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
print "<td align=center><img src=http://www.mydomain.com/images/visitorpics/".$info['photo'] ." width=150 height=150><br><font color=white>".$info['name'] . "</font></td>";
$x++;
if ($x == 5)
{
print "</tr><tr>";
$x=0;
}
}
?>
</tr>
</table>
</font>
</body>
</html>
Now I get a nicely formatted photo gallery that displays a photo and the submitter's name, showing 5 per row.
(Being a newbie really sux) 🙁