Jump to content

[SOLVED] New row automatically


cordoprod

Recommended Posts

Hi.

 

I have a db and i get the username, in profile images.

I fetch the row and then i replace the username with the path to his profile image.

What i want to do is to break the tr and add a new row when it's 3 images.

 

Like this

image1 image2 image3

image4 image5 image6

 

or else it just like this image1 image2 image3 image4 image5 image6

 

$c = 3;
         foreach($rows['visitor'] as $Key => $Value)
        {
    	if(!($Key % $c)) echo "</tr><tr>";
    echo "<td width=\"10%\">"; if(file_exists("images/pg/".$rows['visitor']."_tiny.jpg")) { echo "<a href=\"?s=user&nick=".$rows['visitor']."\"><img class=\"$class\" src=\"images/pg/".$rows['visitor']."_tiny.jpg\" width=\"60\" /></a><br>"; } else { echo "<a href=\"?s=user&nick=".$rows['visitor']."\"><img class=\"$class\" src=\"images/pg/no_picture_tiny.jpg\" width=\"60\" /></a><br>"; } echo "</td>
    <td width=\"90%\"><span class=\"$class2\"><a href=\"?s=user&nick=".$rows['visitor']."\">".$rows['visitor']."</a></span><br />"; time_elapsed_done($rows['tid']); echo "</td>";
}
if(!($Key % $c)) echo "</tr>";

 

When i use that code i get: invalid argument supplied for foreach

Link to comment
https://forums.phpfreaks.com/topic/114512-solved-new-row-automatically/
Share on other sites

something like this?

while($rows = mysql_fetch_array($sql))
{
  if($i == 3){echo "<tr><td> </td></tr>"; }
  echo $rows['visitors'];
  $i++;

}

i think that should work, with some tweaking

 

Almost, if it's more than 6 entries then it just continues on the second row.

1 2 3

4 5 6 7 8 9 10

 

Understand?

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.