Click to See Complete Forum and Search --> : Using Mod Count?


cinematic_jesi
10-06-2008, 03:31 PM
I'm having issues with css in IE7 using div's and display:inline-block.

Well, my co-worker approached me with a different solution, but didn't know how to go about it.

She thought about using a mod-count? Basically its set up so that because the width of the content area that only 4 will show up because of size. She thought that maybe with a mod count I could do a clear:both div after.

Is there a way to implement it into this code?
<?php do { ?>
<div style="display:inline-block; text-align: center; width: 128px; padding: 3px; border: 1px solid #999999; vertical-align: middle; margin: 6px;"><a href="gallery-photos-large.php?Collection=<?php echo $row_Collections['ID']; ?>&Album=<?php echo $row_Albums['ID']; ?>&Photo=<?php echo $row_Photos['ID'];?>#Gallery"><img style="margin:0px;" src="/media/collections/<?php echo $row_Collections['Folder']; ?>/<?php echo $row_Albums['Folder']; ?>/thumb_<?php echo $row_Photos['Filename']; ?>"></a><br><b><a href="gallery-photos-large.php?Collection=<?php echo $row_Collections['ID']; ?>&Album=<?php echo $row_Albums['ID']; ?>&Photo=<?php echo $row_Photos['ID'];?>#Gallery"><?php echo $row_Photos['Caption']; ?></a></b></div>
<?php } while ($row_Photos = mysql_fetch_assoc($Photos)); ?>

lochgo
10-06-2008, 04:09 PM
In regards to display:inline-block and IE, there is a current discussion regarding it here (http://www.webdeveloper.com/forum/showthread.php?t=192848)

cinematic_jesi
10-07-2008, 08:31 AM
I'm still interested in the mod count. I've never heard about it before..

MrCoder
10-07-2008, 09:23 AM
mod is just a mathematical function.

http://en.wikipedia.org/wiki/Modular_arithmetic

Using mod is one of the best ways to condense what would otherwise be bloated code.

I have never heard the phrase "mod count" used to describe it thou.

cinematic_jesi
10-07-2008, 09:45 AM
So.. is there a way to say, after 4 records are generated, with my code above, add <div style="clear:both"></div>.. and then continue with the next row?

cinematic_jesi
10-07-2008, 10:05 AM
I don't know if this would be heading the right way???

<?php if(count($row_Photos) == SOMETHING HERE?) {echo '<div style="clear:both">&nbsp;</div>'; } ?>

Ultimater
10-10-2008, 08:38 AM
for($i=0,$l=mysql_num_rows($Photos);$i<$l;$i++){
$row_Photos=mysql_fetch_assoc($Photos);
$href="gallery-photos-large.php?Collection={$row_Collections['ID']}&amp;Album={$row_Albums['ID']}&amp;Photo={$row_Photos['ID']}#Gallery";
$src="/media/collections/{$row_Collections['Folder']}/{$row_Albums['Folder']}/thumb_{$row_Photos['Filename']}";
echo <<<EOT
<div style="display:inline-block; text-align: center; width: 128px; padding: 3px; border: 1px solid #999999; vertical-align: middle; margin: 6px;">
<a href="$href"><img src="$src"></a>
<br>
<b><a href="$href">{$row_Photos['Caption']}</a></b>
EOT;

//make sure there is no tailing space after EOT;
if($i > 0 && $i % 4==0){echo '<div style="clear:both">&nbsp;</div>';}
}//for