Combining PHP & MySQl.

Discussion in 'PHP' started by Matt2k6, Dec 12, 2006.

  1. #1
    Hey all. Say if i had these columns n rows in a MySQL table:

    Name: Last Name:
    John Philips


    How would i get it using php to display all the data in my database one under the other?

    Thanks.
     
    Matt2k6, Dec 12, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Dude, looking at your posts today, why don't you go read some tutorials or buy a book? You'll keep asking all these questions all day long unless you educate yourself.

    This is so basic but you only provide one piece of the puzzle. We can't help like this.
     
    T0PS3O, Dec 12, 2006 IP
  3. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
  4. thedark

    thedark Well-Known Member

    Messages:
    1,346
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    168
    Digital Goods:
    1
    #4
    i reccomend "John Wiley & Sons - Beginning PHP, Apache, MySQL Web Development" book, everything you must know is there.
     
    thedark, Dec 12, 2006 IP
  5. adsblog

    adsblog Active Member

    Messages:
    659
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #5
    you sould known SQL commands to excute and get information from database .

    - you connect to database ( mysql_connect )
    $link=mysql_connect($server_host,$user,$pass);
    PHP:
    - you select a database ( Select DB )
    mysql_select_db($dbname,$link);
    PHP:
    - you set a query for get information from DB ( SQL Queries )
    $query = "SELECT `name`,`lastname` FROM table_name";
    PHP:
    - you excute that's Query ( Query Excute )
    $result=mysql_query($query);
    PHP:
    - you use a circle to get all information from query result .(Fetch Arrays )
    while ($user = mysql_fetch_array($result )) {
             print "name : " .$user['name'] ."Last name : ". $user['lastname'];
    }
    PHP:
    - Finished . [ Learn more about While Circle ]

    i recommend you see php reference website . ( http://www.php.net ) and Documentation ( http://ir.php.net/docs.php )

    have a nice day :)
     
    adsblog, Dec 12, 2006 IP
  6. adsexper

    adsexper Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This is indeed a very generic question and there is no way we can answer that in 1 post as it will trigger more questions. I suggest that you take a look at a tutorial, here is one that looks good:
    http://www.php-mysql-tutorial.com/connect-to-mysql-using-php.php

    it will give you the idea.
     
    adsexper, Dec 13, 2006 IP