Results 1 to 2 of 2

Thread: Dynamically count the remain of items max 5 per line

  1. #1
    Join Date
    Jun 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamically count the remain of items max 5 per line

    Hello,
    i have many categories, each category have one or more items inside it. i'm displaying each category and its items under it in lines with max number of items per line.
    ex:
    (the data coming from database dynamically).

    PHP Code:
    Category 1

    item1    item2    item3    item4    item5

    item6    item7 
    or

    PHP Code:
    Category 2

    item1    item2 
    the question is :
    Using PHP how to know the remain numbers of items in the line [ If i have 2 items under the category how to know that it remains 3 to complete the line and if i have 1 item under the category, how to know that it remains 4 to complete the line and so on]

    i want to know how many items remains in the row.

    i do not know how many categories or items exist.

    please i want it as quickly as possible

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sure. Just count it when you get the information from the database.

    For example, mysql_num_rows($query_result) will tell you the number of matches (total).

    Or if you are using a while/for loop, you can simply count how many times you find a match.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •