How can I echo all rows in a table

Discussion in 'Programming' started by mnymkr, Nov 15, 2006.

  1. #1
    Is there a way to show all rows in a database table without having to echo row[0] echo row [1] for each field?


    also how does one write code so it appears as code on a webpage. like it is done when u use the code button here?
     
    mnymkr, Nov 15, 2006 IP
  2. namd3r

    namd3r Active Member

    Messages:
    135
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    "http://www.thescripts.com/forum/thread541222.html"
     
    namd3r, Nov 16, 2006 IP
  3. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    
    //Make your query and store it in $result
    
    while ($row = mysql_fetch_assoc($result)) 
    {
       echo $row['youFieldName'];
    }
    
    Code (markup):
     
    giraph, Nov 16, 2006 IP
  4. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #4
    As far as having code appear like it does on this webpage, you can surround it in <pre> tags to specify that it is preformated. IE:
    
    <pre>
    This text    is formatted
    and breaks do not
    need to be added anywhere.
    </pre>
    
    Code (markup):
     
    giraph, Nov 16, 2006 IP