perezf Posted May 17, 2008 Share Posted May 17, 2008 How can i make it so for every 3 items that are listed display a break. For instance say i have 6 items total, How can i make it show 3 per row This is what i currently have <?php for ($i=1;$i <= $numberofrows;$i++) { $portitem = mysql_fetch_array($result); if($portitem['imgsrc'] == NULL) { $imagesrc = '/portimages/defaultNULL.jpg'; } else { $imagesrc = '/portimages/' . $portitem['imgsrc']; } $takefirstpart = str_split($portitem['name'],5); $therestofthetitle = substr($portitem['name'],5,1000); if(strlen($portitem['domain'])>30) { $domaindisp = substr($portitem['domain'],0,30) . '...'; } else { $domaindisp = $portitem['domain']; } $imagesrc = "http://www.shrinktheweb.com/xino.php?embed=1&u=1a2b4&STWAccessKeyId=c785d563c560198&Size=lg&Url=" . $portitem['domain']; if($i%2) { print '<div class="sideones">'; print '<div class="sideshead"><h1>' . '<span class="orangetxtcolor">' . $takefirstpart['0'] . '</span>' . $therestofthetitle . '</h1></div>'; print '<div class="sidescontent">'; print '<a href="http://www.' . $portitem['domain'] . '" title="Click Here to go to ' . $portitem['name'] . '\'s Website"><img src="' . $imagesrc . '" width="230" height="126" alt="' . $portitem['name'] . '" border="0" target="_blank" style="padding-bottom: 10px;" /><br /><span class="spanlink">www.' . $domaindisp .'</span></a>'; print '</div>'; print '</div>'; } else { print '<div class="middleone">'; print '<div class="middlehead"><h1>' . '<span class="orangetxtcolor">' . $takefirstpart['0'] . '</span>' . $therestofthetitle . '</h1></div>'; print '<div class="middlecontent">'; print '<a href="http://www.' . $portitem['domain'] . '" title="Click Here to go to ' . $portitem['name'] . '\'s Website"><img src="' . $imagesrc . '" width="230" height="126" alt="' . $portitem['name'] . '" border="0" target="_blank" style="padding-bottom: 10px;" /><br /><span class="spanlink">www.' . $domaindisp .'</span></a>'; print '</div>'; print '</div>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/106025-solved-listing-items-help/ Share on other sites More sharing options...
cooldude832 Posted May 17, 2008 Share Posted May 17, 2008 first the more commonly accept mysql query of an arra yto list is while($row = mysql_fetch_XXXX($result) over the for (rowcount) verrsion any way what you do is you have something like <?php $i = 1; while($row = mysql_fetch_assoc($r)){ #check here if($i%3 == 0){ #new row break line for your code } #display stuff $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/106025-solved-listing-items-help/#findComment-543384 Share on other sites More sharing options...
perezf Posted May 17, 2008 Author Share Posted May 17, 2008 That worked perfectly ;D ;D ;D ;D ;D ;D Link to comment https://forums.phpfreaks.com/topic/106025-solved-listing-items-help/#findComment-543389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.