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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.