runthis Posted July 12, 2010 Share Posted July 12, 2010 When im displaying a list of data horizontally it overflows out of the table, doing overflow:hidden in css only hides what i want to display, how do i get the data to just jump one line down when its reached the maximum width i allow Quote Link to comment https://forums.phpfreaks.com/topic/207514-display-problem/ Share on other sites More sharing options...
robert_gsfame Posted July 12, 2010 Share Posted July 12, 2010 just create a condition then.. $td=1; then loop $td...after reach a total <td> you wish to have then if($td==3){ echo "</tr><tr>"; ==>close and create new line... n dont forget to set back your $td $td=1;} hope it helps Quote Link to comment https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084905 Share on other sites More sharing options...
runthis Posted July 12, 2010 Author Share Posted July 12, 2010 i was hoping for a fancier way than putting an if statement in my loop Lets say i display 20 items and the last 2 are off the page, ok i set my if statement to 18 and throw in the <tr></tr> to display the next 2 underneath that means if i want the user to display 56 things i have to code if 18 <tr></tr> if 36<tr></tr> Thats bad coding, is there a better way? Quote Link to comment https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084909 Share on other sites More sharing options...
runthis Posted July 12, 2010 Author Share Posted July 12, 2010 Nevermind i didnt see your setback idea as well, im gonna try it then hit solved Quote Link to comment https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084911 Share on other sites More sharing options...
Pikachu2000 Posted July 12, 2010 Share Posted July 12, 2010 Is the data for the fields coming from a database query? Quote Link to comment https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084912 Share on other sites More sharing options...
robert_gsfame Posted July 12, 2010 Share Posted July 12, 2010 okay fast coding assume i have 15 records n i wish each row to have only 2 records to be displayed then i will do like this <table><tr> <?php $myrecord=array("bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla"); $td=1; for($i=0;$i<count($myrecord);$i++){ if($td==3){ echo "</tr><tr>"; $td=1;} echo "<td>$myrecord[$i]</td>"; $td++; } ?> </tr></table> Quote Link to comment https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084916 Share on other sites More sharing options...
runthis Posted July 12, 2010 Author Share Posted July 12, 2010 Got it on the first post. Quote Link to comment https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.