phpQuestioner Posted October 16, 2007 Share Posted October 16, 2007 what would be the best way to display on a specific number of database variables in a list or td? example Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 Item 9 or if an item was missing; the list/td would not have any empty spaces - like this: Item 2 Item 3 Item 5 Item 6 Item 7 Item 8 Item 9 would i do this with a limit or explode or what? i have seen this done, but not sure how to achieve it. i do not know if they were using 1 variable or more then 1 variable. if any one knows what i am trying to convey and knows what would be the best way to do this - please let me know - thanks. Quote Link to comment https://forums.phpfreaks.com/topic/73421-solved-how-to-display-only-a-specific-number-of-items-from-database-in-each-listtd/ Share on other sites More sharing options...
phpQuestioner Posted October 16, 2007 Author Share Posted October 16, 2007 ok - so I got started on a script; but I cannot figure out how to display only 3 list item in one <td> and then close the </td> and create another <td> and display 3 more list items from the variable. can someone look at this code and tell me where to go from here? the way that the above post looks like (in the example I gave) is what I am trying to do. Here's what I have so far. <?php $features = "muilt disc cd player, dual heat and a/c, leather seat, captain chairs, dvd player, play station 3"; echo "<table><td><ul>"; $splitup = explode(", ", $features); for($i = 0; $i < count($splitup); $i++){ if ($i > 3) { echo "<table cellpadding=0 cellspacing=0>"; echo "<td>"; echo "<li>$splitup[$i]</li>"; echo "</td>"; echo "</table>"; } else { echo "<li>$splitup[$i] </li>"; } } echo "</ul></td></table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/73421-solved-how-to-display-only-a-specific-number-of-items-from-database-in-each-listtd/#findComment-370419 Share on other sites More sharing options...
ryeman98 Posted October 16, 2007 Share Posted October 16, 2007 I'm not exactly sure how you want to display it but maybe you could play around with the code here: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/73421-solved-how-to-display-only-a-specific-number-of-items-from-database-in-each-listtd/#findComment-370421 Share on other sites More sharing options...
phpQuestioner Posted October 16, 2007 Author Share Posted October 16, 2007 ok - let me try this question; how can I have my php script look at a certain variable in and only display say maybe the first 3 word from that variable and then after it finds the first three words in this variable it would display 3 more words from this variable? if i use a "for" loop to get the first 3; how can i get the next three and eliminate the previous three from being displayed again? Quote Link to comment https://forums.phpfreaks.com/topic/73421-solved-how-to-display-only-a-specific-number-of-items-from-database-in-each-listtd/#findComment-370436 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.