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

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.