Jump to content

[SOLVED] Insert </tr><tr> every 4 loops. With pictures.


maGGot_H

Recommended Posts

I can't believe i stucked on such thing.

There is an uncertain number of pictures that need to be displayed reverse (new ones before old ones) 4 in a row.

And after every 4 loops the script must insert </tr><tr> until the loop come to an end (0).

I decided to move this way:

  
$rows=mysql_num_rows($cmd_rows); // THAT NUMBER OF PICTURES
  echo '<table><tr>';
   for ($view=$rows-1;$view>=0;$view--) {
   if ($view%4==0) { echo '</tr><tr>';}
  echo '
<td>//PIECE OF CODE //</td>
';
      }
echo '</tr></table>';

 

But i've met that if the number of pictures splits on 4 at once (before there are 4 loop circles), the script insert the </tr><tr> at the start of the page as i told him.

How can i reslove this problem? TO have 4 pictures in a row independently of the number of pictures.

Pardon me if you notice any mistakes in my English =).

 

Images included:

 

[attachment deleted by admin]

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.