dezkit Posted November 4, 2008 Share Posted November 4, 2008 Hi guys, how do I make it so that whenever 3 Entries get echo'd a new <tr> appears? <table width="600" style="height:146px;" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="100" style="height:60px;"><p style="margin:0 0 0 0"><a href=""><img style="margin:0 0 0 0;" src="images/example.jpg" width="83" height="60" alt="" border="0"></a></p></td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
F1Fan Posted November 4, 2008 Share Posted November 4, 2008 Create a variable, increment it for each DB table row, and if it's 3, reset it and echo </tr><tr>. Quote Link to comment Share on other sites More sharing options...
dezkit Posted November 4, 2008 Author Share Posted November 4, 2008 Gah, are there any tutorials on this? Google doesn't help Quote Link to comment Share on other sites More sharing options...
F1Fan Posted November 4, 2008 Share Posted November 4, 2008 Show your code. You're only showing part of it. Show the part with the loop. Quote Link to comment Share on other sites More sharing options...
dezkit Posted November 4, 2008 Author Share Posted November 4, 2008 <?php include("./config.php"); $result = mysql_query("SELECT * FROM gallery") or die(mysql_error()); echo "<table width=\"600\" style=\"height:146px;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; while($row = mysql_fetch_array( $result )) { echo "<td width=\"100\" style=\"height:60px;\"><p style=\"margin:0 0 0 0\"><a href=\"#\"><img style=\"margin:0 0 0 0;\" src=\"./uploads/" . echo $row['thumburl'] . "\" width=\"83\" height=\"60\" alt=\"\" border=\"0\"></a></p></td>"; } echo "</table>"; After 3 rows get <td>'s gtt echo'd i want a new <tr>!! Quote Link to comment Share on other sites More sharing options...
F1Fan Posted November 4, 2008 Share Posted November 4, 2008 echo "<table width=\"600\" style=\"height:146px;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; $rows = 1; while($row = mysql_fetch_array( $result )) { if ($rows==1) echo "<tr>"; echo "<td width=\"100\" style=\"height:60px;\"><p style=\"margin:0 0 0 0\"><a href=\"#\"><img style=\"margin:0 0 0 0;\" src=\"./uploads/" . echo $row['thumburl'] . "\" width=\"83\" height=\"60\" alt=\"\" border=\"0\"></a></p></td>"; if ($rows==3){ echo "</tr>"; $rows = 0; } $rows++; } echo "</table>"; Quote Link to comment Share on other sites More sharing options...
Michdd Posted November 4, 2008 Share Posted November 4, 2008 Not sure if this is what you wanted... <?php include("./config.php"); $result = mysql_query("SELECT * FROM example") or die(mysql_error()); echo "<table width=\"600\" style=\"height:146px;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; $count = "0"; while($row = mysql_fetch_array( $result )) { $count++; echo "<td width=\"100\" style=\"height:60px;\"><p style=\"margin:0 0 0 0\"><a href=\"#\"><img style=\"margin:0 0 0 0;\" src=\"./uploads/" . echo $row['thumburl'] . "\" width=\"83\" height=\"60\" alt=\"\" border=\"0\"></a></p></td>"; if($count => "3"){ echo "</tr><tr>"; $count = "0"; } } echo "</table>"; Quote Link to comment Share on other sites More sharing options...
dezkit Posted November 4, 2008 Author Share Posted November 4, 2008 It says "Parse error: syntax error, unexpected T_ECHO in /home/cobi/public_html/gallery.php on line 85" Line85: echo "<td width=\"100\" style=\"height:60px;\"><p style=\"margin:0 0 0 0\"><a href=\"#\"><img style=\"margin:0 0 0 0;\" src=\"./uploads/" . echo $row['thumburl'] . "\" width=\"83\" height=\"60\" alt=\"\" border=\"0\"></a></p></td>"; Thanks, guys. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted November 4, 2008 Share Posted November 4, 2008 You have an extra echo in that line: echo "<td width=\"100\" style=\"height:60px;\"><p style=\"margin:0 0 0 0\"><a href=\"#\"><img style=\"margin:0 0 0 0;\" src=\"./uploads/" . $row['thumburl'] . "\" width=\"83\" height=\"60\" alt=\"\" border=\"0\"></a></p></td>"; Quote Link to comment Share on other sites More sharing options...
dezkit Posted November 4, 2008 Author Share Posted November 4, 2008 OMG! It works perfectly, THANKS SO MUCH <33 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.