1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Echo $row ['firstname']

Discussion in 'PHP' started by gether, Jan 28, 2013.

  1. #1
    i was trying to do a simple college project .. with the help of

    html php and mysql


    i was wondering which are all the parts of a php program in that line

    echo $row ['firstname']

    i have a confusion about which belongs to what ..

    especially when dealing with html php and mysql
     
    gether, Jan 28, 2013 IP
  2. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    echo (display to the web page)
    $row (coming from a data base row)
    ['firstname'] (the data coming from database under First Names

    Its a handler dealing with data that has been called above it in SQL and the PHPscirpt is calling fields and data from the SQL database, in that case you're showing. Its pulling the first name. You have all the rest of those missing/not posted.

    The code you posted is PHP. The code above it (not showing) would be SQL with something like
    SELECT * FROM tablename .Once SQL pulls all the data , it has to be put into usable form for PHP. That's where you see PHP script dividing the data with $row ['firstname']
    and its echoing (displaying it to the page) you can further turn this into usable variable with
    $firstname = $row['firstname'];

    and so on..
     
    ezprint2008, Jan 28, 2013 IP
  3. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    i am using html php and mysql

    echo is part of php
    $row is part of php

    ['fieldname'] or ['labelname'] is part of an html form or mysql table

    $ does that dollar sign standing alone means anything ?

    i thought it was used to represent a variable name ?
     
    gether, Jan 28, 2013 IP
  4. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #4
    yes, the $row is a PHP var.
    Read the PHP tutorials or start with a book gether. In 6 months you won't have any questions about those simple things.
     
    ezprint2008, Jan 28, 2013 IP
  5. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    "$row" as a whole is a php variable ?

    i have seen variable names starting like $somevariablename

    so is it ok to call $row ..... $somevariablename

    ?
     
    gether, Jan 28, 2013 IP
  6. Xtrapsp

    Xtrapsp Active Member

    Messages:
    716
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #6
    Well,

    $blabla =

    Would be you making your own Variable, and this can be used with the standard PHP Variables (Ones which come by default) such as $row[''];

    For Example,

    $Customer_First_Name = $row['CFirstname'];
    echo $Customer_First_Name;
    PHP:
    So $row['CFirstname']; Finds the row inside your database called CFirstname and places the details of that into the custom made Variable.

    I then simply echo'd the variable :)
     
    Xtrapsp, Jan 28, 2013 IP
  7. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #7
    ok thanks.. its a default part of that php programming language...
    "echo" too is a default part of the programing language ?
     
    gether, Jan 28, 2013 IP
  8. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #8
    Gether, PHP,MySql, Apache book is for you.
    It's probably at Amazon etc.
    If you need to, go sell a couple of my programs and I'll buy you one.
    Then you pay me back in 2 years when you sell your own programs OK?
     
    ezprint2008, Jan 28, 2013 IP
  9. Xtrapsp

    Xtrapsp Active Member

    Messages:
    716
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #9
    Indeed it is,

    Echo, Print, $Row[''],$_GET[''],$_POST['']

    Those are all defaults and more :)
     
    Xtrapsp, Jan 28, 2013 IP
  10. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #10
    nice.. so .. yea.. staying with the programming defaults.. learned a few important things online.. there was almost no education offline.. lol
     
    gether, Jan 28, 2013 IP
  11. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #11
    Sams Teach Yourself PHP, MySQL and Apache All-in-One

    this one ?
     
    gether, Jan 28, 2013 IP
  12. Xtrapsp

    Xtrapsp Active Member

    Messages:
    716
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #12
    You can always learn offline ^^, theres plenty of books in libraries etc.

    I suggest Thenewboston
     
    Xtrapsp, Jan 28, 2013 IP
  13. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #13
    Which ever one you want gether.
    If it helps you do what you want to do.
     
    ezprint2008, Jan 28, 2013 IP
  14. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #14
    lol .. this may sound really stupid.. but let me try to remove that $sign from everywhere and see what that code does....
     
    gether, Jan 28, 2013 IP
  15. Xtrapsp

    Xtrapsp Active Member

    Messages:
    716
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #15
    That would most likely just throw errors
     
    Xtrapsp, Jan 28, 2013 IP