SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jul 2010
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    If $opname is an array containing:
    ['this', 'that', 'other']

    $opname[0] is 'this'
    $opname[1] is 'that'
    $opname[2] is 'other'

    The count for the array is 3, as there are three items in the array.
    Your code sample is setting $totalarr to the last index number of the array.

    With the mysql_num_rows code, similar behaviour is occurring there too.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •