Results 1 to 3 of 3

Thread: reading table[RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144

    Resolved reading table[RESOLVED]

    How can i read the info on a mysql table and then put it the data into a html table?

    This uses PEAR, but is there away to do without it?
    PHP Code:
        <html>
        <body>
        <?php    
            
    // establish a dsn string (this should actually be done in a header file)
            
    $dsn = array('phptype' => 'mysql''hostspec' => 'localhost''database' => 'tommy''username' => 'table'

    'password' => '');
            
    $db DB::connect$dsn); 
            
    $rsUser $db->query("SELECT Name, Type, Date/Time, Format, Version FROM table");
            
    $table = new HTML_Table (Array ("border" => "1""width" => "50%""align" => "center"));
            
    $table->addRow(Array("Name""Type""Format""Version""Download""Download Compressed File"), ""

    "TH");
            
            while (
    $rsUser->fetchInto($rowUserDB_FETCHMODE_ASSOC)) {
                
    extract ($rowUser);
                
    $rowUser["Name"] = "<A HREF = 'viewprofile.php?user=$username'>$username</A>";        
                
    $rowUser["Download"] = "<A HREF = '$username&/$type/&$date/'>Download</A>";
            
    $rowUser["Download Compressed File"]  = "<A HREF = 

    'compress.php?
    $username&$type&$date'>Zip file</A>"
                
    $rowUserProcessed = Array();
                foreach (
    $rowUser as $field$rowUserProcessed[] = $field;
                
                
    // add the row to the HTML table
                
    $table->addRow($rowUserProcessed);
            }
            
    $db->disconnect();
            
            
    $table->altRowAttributes (1"style = 'background-color: #CCCCCC'""style = 'background-color: 

    #EEEEEE'"
    );    
            
    $table->setRowAttributes (0"style = 'background-color: #000000; color: #FFFFFF'");
            
    $table->display();
        
    ?>
        </body>
        </html>
    Last edited by Tommy101; Sep 26th, 2005 at 03:00 PM.


    Msn Messenger is the Best

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width