Results 1 to 3 of 3

Thread: reading table[RESOLVED]

  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

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: reading table

    You can use the built in MySql functions. The PEAR class is just a wrapper for these:

    http://www.php.net/mysql
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

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

    Re: reading table

    thanks for helping


    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