Jump to content

[SOLVED] Next row after 3 mysql entries have been echo'd


dezkit

Recommended Posts

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>

<?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>!!

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>";

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>";

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.

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>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.