Jump to content

"if" statement to arrange images


akumakeenta

Recommended Posts

Hi all again,

 

I have a script that will process all images and place them all in one row.

 

What I need help with is, to place to 2 images in one row and then start a new row and place two more images etc.

 

Here is the code:

 

 

<table cellpadding="5" class="adpics" width="100%" border="0">

<tr>

<?php

while ($row = mysql_fetch_array($pres))

{

$i++;

 

$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $images_max_width, $images_max_height);

 

?>

<td>

<img src="<?php echo "{$datadir[adpics]}/{$row[picfile]}"; ?>" id="adimg<?php echo $i; ?>" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>">

</td>

 

 

<?php

}

?>

 

</tr>

</table>

 

thanks again for your help.

Link to comment
Share on other sites

$count = 1;
$column = 1; 					
echo '<table cellpadding="5" class="adpics" width="100%" border="0">';
while ($row = mysql_fetch_array($pres))
{
if ($column == 1){
	echo "<tr>
			<td>".$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $images_max_width, $images_max_height)."</td>";
}else{
	echo "<td>".$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $images_max_width, $images_max_height)."</td>";("<td></tr>";
}
}
$count += 1;
$column = $count % 2;

Link to comment
Share on other sites

Thanks I hope i can figure it out...I was just hoping for someone to just say type this....lol

 

That's pretty much what that mini tutorial does, and you get to learn how its done. Save you coming back again latter and asking the same question.

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.