SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help: To display database content in a table

    Ok, i tried to search a post like this one, but i was unable to get an answer, I hope i'm not posting an already posted question...

    What I want to do:
    I want to display all the content of this a database table (agenda) like this:
    Code:
    Tom Jones  969012345 tom@example.com  1989-01-19
    Bob Smith  937890123 bob@example.com  1989-08-02
    Biff White 912345678 biff@example.com 1965-03-08
    Todd Brown 965678901 todd@example.com 1987-04-22
    my attempt was:
    PHP Code:
    <?php
    $db 
    mysql_connect("localhost","adantas_abeldant",">pass<");
    mysql_select_db("adantas_phptestdb",$db);


    $sql_result mysql_query("SELECT * FROM agenda"$db);

    $rs mysql_fetch_row($sql_result);
    echo 
    $rs[];
    ?>
    and i got something was this:
    Tom Jones


    can you help me? if you need any more information please tell me...
    Last edited by r937; Dec 24, 2007 at 19:54.

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    while($rs mysql_fetch_array($sql_result)){
    print 
    $rs['fieldOne']." ".$rs['fieldTwo']." etc<br/>";


  3. #3
    SitePoint Evangelist Waffles's Avatar
    Join Date
    Nov 2005
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    // if you want it in an actual table, something like this..
    echo '<table width="500">'// start a table..

    while($rs mysql_fetch_array($sql_result)){

    echo 
    '<tr><td>'.$rs['fieldone'].'</td><td>'.$rs['fieldtwo'].'</td></tr>';

    // start a new row each record and open and close an appropriate amount of <td> columns



    echo 
    '</table>'// close table 

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Waffles & mudshark that was exacly what i wanted...


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
  •