Results 1 to 4 of 4

Thread: Count and rows code

  1. #1
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default Count and rows code

    What is the explanation or meaning of this code:

    PHP Code:
    $totalarr count($opname) - 1
    and

    PHP Code:
    $totalrows mysql_num_rows($result);
            
    $trows $totalrows 1
    Thank you
    Last edited by rhodarose; 12-13-2010 at 02:02 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    count() counts the number of elements in an array

    PHP Code:
    $array = array('Dog''Cat''Apple''Pear');
    echo 
    count($array); // 4 
    mysql_num_rows() returns the amount of returned rows from a query.
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    rhodarose (12-13-2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Nile View Post
    count() counts the number of elements in an array

    PHP Code:
    $array = array('Dog''Cat''Apple''Pear');
    echo 
    count($array); // 4 
    mysql_num_rows() returns the amount of returned rows from a query.
    and why the totalrows result need minus 1?

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    It depends on where it's being used - it's just subtracting one away probably for a reason that comes up later in the script. I dont know.
    Jeremy | jfein.net

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
  •