I am a neewbie. Recently time which I have begun to program in PHP with MySQL, and I need to solve a problem.
I have a table that relates all the registries of a table in a database MySQL which begin by a letter, ordered of ascending form.
Table HTML must consist of limitless rows and 4 columns
I have all the code, unless not like inserting tags </tr><tr> each 4 rows. Please, somebody can help me?
I stick the code fragment so that it is understood well...
<?
$dbhost="localhost";
$dbusuario="***";
$dbpassword="***";
$db="genea";
$conexion = mysql_connect($dbhost, $dbusuario, $dbpassword);
mysql_select_db($db, $conexion);
?>
<?
$query="SELECT * FROM nombres WHERE nombre LIKE '$letra%' ORDER BY nombre ASC";
$result=mysql_query($query, $conexion);
$num=mysql_numrows($result);
echo"<table border='0' width='100%' cellspacing='5' cellpadding='10'>";
while($row=mysql_fetch_row($result))
{
echo"<td class='row2' width='25%' align='left'><span class='topictitle'><a class='topictitle' href='http://www.---.com/nombres.php?nombre=$row[1]'><b>$row[1]</b></a></span></td>";
}
echo"</table>";
mysql_close($conexion);
?>
In order to open to each page of each initial letter the connection it would be this:
[url]http://www.---.com/letras.php?letra=A[/url]
I summarize. I need the data appear in a table that has 4 columns. I always need that each 4 results this code is inserted:
</tr><tr>
in case that there is more than 4 results.
Now in my script has a <td></td> for each entry in the database. But i wish that each 4 entries has </tr><tr>, so that the table only has four columns.
Thanks (i speak english only a litte. Excuse me)