how to display data from mysql in php

Discussion in 'PHP' started by luca_p7, Sep 18, 2006.

  1. #1
    hello
    i m new with php(1 week) and i need to display the data from my data base into php.
    the data i want to display should be displayed grid like
    i cand do that but in a very ugly and not good way.
    pls if u can help me with:
    1) customizing the grid.
    2) displayng the headers of the grid
    3) displaing the data in the right manner so if i must to be albe to change just the things i must change and not the entire table.

    your help would be more than appreciated.

    P.S. i m a noob sou i would appreciate if your answer would be eazy to understand and to follow.

    there is my code:
    ......................................................
    $result=mysql_query($query)
    or die("SELECT Error: ".mysql_error());
    $num_rows = mysql_num_rows($result);
    print "<table style=text-align:center bgcolor=#E4E2D6 width=453 border=0 cellpadding=0 cellspacing=0 class=text><tr><td><a class=meniuri>nr</a></td><td><a class=meniuri>tip utilaj</a></td><td><a class=meniuri>categorie</a></td><td><a class=meniuri>marca</a></td><td><a class=meniuri>model</a></td><td><a class=meniuri>an fab.</a></td><td><a class=meniuri>putere</a></td><td><a class=meniuri>viteza</a></td><td><a class=meniuri>pret</a></td><td><a class=meniuri>foto</a></td></tr></table>";
    print "<table style=text-align:center width=453 border=0 cellpadding=0 cellspacing=0 class=text>\n";
    while ($get_info = mysql_fetch_row($result)){
    print "<tr>\n";
    foreach ($get_info as $field)
    print "\t<td bgcolor=#E4E2D6 width=35 ><font scope=row/>$field</font></td>\n";
    print "\t<td bgcolor=#E4E2D6><img src='img/tr1.jpg'/></td>\n";
    print "</tr>\n";
    }
    print "</table>\n";
    print"<a class=text size=12 style=color:#e27603>$num_rows inregistrari</a>";
    ........................
     
    luca_p7, Sep 18, 2006 IP
  2. ip076

    ip076 Peon

    Messages:
    79
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not sure what you mean by point #3, but I wrote this class a while ago that should help you out with the other two.
     
    ip076, Sep 18, 2006 IP
  3. luca_p7

    luca_p7 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    iti multumesc foarte muuult.:D
    that means thank you very much.:D
    il try your class tonight when il arrive home.
    you are a life saver.
     
    luca_p7, Sep 19, 2006 IP
  4. comxian

    comxian Member

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    thanks buddy. useful information
     
    comxian, Sep 18, 2010 IP
  5. almedajohnson

    almedajohnson Peon

    Messages:
    140
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    very well done dear. The class is very helpful. Share your other resources if you have.
     
    almedajohnson, Sep 21, 2010 IP
  6. comxian

    comxian Member

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #6
    i tried this code, it helped me to retrieve records from a database,than u so much
     
    comxian, Oct 19, 2010 IP