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
https://forums.phpfreaks.com/topic/194395-if-statement-to-arrange-images/
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;

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.