SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast rajesh_pila's Avatar
    Join Date
    Nov 2004
    Location
    chennai
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Execute MySQL queries and output results in tables

    Hi all
    Can anyone tell me how do i execute MySQL queries and output results in tables.

    Please help i am in urgent requirement

    Thanks and regards

    rajesh
    Success comes to them, those who dares to fight
    www.geocities.com/mayavirajesh

  2. #2
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajesh_pila
    Hi all
    Can anyone tell me how do i execute MySQL queries and output results in tables.

    Please help i am in urgent requirement

    Thanks and regards

    rajesh
    Rajesh, can you explain your problem a little better?
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  3. #3
    SitePoint Enthusiast Sneef's Avatar
    Join Date
    Feb 2005
    Location
    Quebec, Canada
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's what I think you want:

    PHP Code:
    <?php

    // This selects all items in a db table
    $select_all mysql_query ("SELECT * FROM table_name");

    // This creates an array(object) with all you selected
    while ($table_name mysql_fetch_object ($select_all))
      {
        
    $field1$table_name->field1;
        
    $field2$table_name->field2;

    // This creates the rows with the appropriate columns
        
    $view_row.= "<tr><td>".$field1."</td><td>".$field2."</td></tr>";
      }
    ?>
    HTML Code:
    <table>
    
    <!-- This creates a title row (optional - tells you the columns contents) -->
    <tr><td>Field 1</td>
        <td>Field 2</td></tr>
    
    <!-- This displays all the rows selected in query on after the other-->
    <?php echo $view_row;?>
    </table>
    You didn't specify what type of query, so I assumed it was a simple SELECT. If not, check out MySQL Manual to get other queries available and how to implement them.

    -Sneef


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
  •