1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

are they accurate comments?

Discussion in 'PHP & Perl' started by thelibertarian, Mar 18, 2013.

  1. thelibertarian

    thelibertarian Newbie

    Joined:
    Mar 13, 2013
    Messages:
    9
    Likes Received:
    0
    Occupation:
    INDEPENDENT CONTRACTS
    Location:
    DENVER
    Home Page:
    Regarding the following line of code... I have broken the rules of programming, for the sake of breaking apart each component of a single line of code, and add comments to describe each...
    My comments are probably incorrect & but thats my question... are they accurate comments?
    If not accurate, please let me know
    I am trying to fully undertand this...


    Line of code in question...

    PHP:
        echo '<h2>' $stuff['heading'] . '</h2>';

    same code... after being broken down to each component with comments...


    PHP:
    //This is what I understand, probably incorrectly...

    //this is defining the array name as $stuff
    while($stuff mysql_fetch_array($query)) {

    //this tells the system to display on screen
          
    echo 

    //this opens the header-2 css tag
    '<h2>'

    //this combines more than 1 thing's, as 1 group-thing
     


    //this is the array name
    $stuff

    //this USES the data from the database already defined as heading (wherever that needs to be & whatever that is and can change via phpmyadin... 
    //this is a question on hold for later)
    ['heading']

    //this combines more than 1 things, as 1 group-thing
     


    //this closes the open header-2 css tag
    '</h2>'

    //this is the end
    ;
    **Thanks in Advance ;)**
     
  2. thelibertarian

    thelibertarian Newbie

    Joined:
    Mar 13, 2013
    Messages:
    9
    Likes Received:
    0
    Occupation:
    INDEPENDENT CONTRACTS
    Location:
    DENVER
    Home Page:
    Is this more accurate than the previous post i left?

    PHP:
        //This is what I understand, probably incorrectly...    //this is defining the array name as $stuff
        
    while($stuff mysql_fetch_array($query))
        
    //this is the beggining of the array    {
        //this tells the system to display on screen    echo
        //this opens the header-2 html/css tag    '<h2>'
        //this is concatenating two or more strings    .
        //this is the array of the result set from the Database    $stuff
        //this is the value from the database of the heading column, based on you selection.    ['heading']
        //this is concatenating two or more strings    .
        //this closes the open header-2 /htmlcss tag    '</h2>'
        //this is the end of the array    ;
        
    **Thanks in Advance ;)**
     
  3. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,143
    Yes, your comments are right.

    PHP:
    while (...) { }
    is the loop structure
    PHP:
    $stuff
    is a variable that holds an associative array as a result of the
    PHP:
    mysql_fetch_array()
    function
    PHP:
    $stuff["heading"]
    holds the value the array stored in $stuff contains for the key "heading".
     
    • Thanks Thanks x 1