jigsawsoul Posted October 30, 2010 Share Posted October 30, 2010 <?php $result = "SELECT * FROM portfolio"; $result = mysql_query ($result) or die (mysql_error()); $i=0; while($row = mysql_fetch_assoc($result)) { if($i==0) echo '<div class="portfolioPage">'; if($i==2) $divclass = 'portfolioProjectWrapper borderWhite'; else $divclass = 'portfolioProjectWrapper borderGray'; echo ' <div class="'.$divclass.'"> <a href="portfolioPage.html" class="image asyncImgLoad" title="img/'.$row['image290x290'].'"></a> <p class="imageDesc">'.$row['image290x290_phot'].'</p> <h3 class="title">'.$row['title'].'</h3> <p class="subtitle">'.$row['subtitle'].'</p> <p class="desc"> '.substr($row['description'], 0, 1200).' <a href="portfolioPage.html" class="commonLink">Read more</a> </p> </div> '; if($i==2) echo '</div>'; if(i==2) $i=0; else $i++; } ?> Please help me im backward at this been along time. Link to comment https://forums.phpfreaks.com/topic/217312-easier-way-to-write-this-simple-code/ Share on other sites More sharing options...
Yucky Posted October 30, 2010 Share Posted October 30, 2010 Rather than just tidying it up, I'd suggest trying to find a better solution that perhaps doesn't involve the $i counter. What are you trying to achieve (in more detail than I can glean from the code)? Link to comment https://forums.phpfreaks.com/topic/217312-easier-way-to-write-this-simple-code/#findComment-1128454 Share on other sites More sharing options...
jigsawsoul Posted October 31, 2010 Author Share Posted October 31, 2010 Yeah I understand but im new to php is there away you could subject or anyone could? Link to comment https://forums.phpfreaks.com/topic/217312-easier-way-to-write-this-simple-code/#findComment-1128607 Share on other sites More sharing options...
litebearer Posted October 31, 2010 Share Posted October 31, 2010 It helps if you clearly explain your objective, then we can help 'clean up' Link to comment https://forums.phpfreaks.com/topic/217312-easier-way-to-write-this-simple-code/#findComment-1128609 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.