Jump to content

[SOLVED] How To Display Only A Specific Number of Items From Database In Each List/TD?


Recommended Posts

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.

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>";

?>

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.