Advertisement
Guest User

Db 2 HTML Class

a guest
Sep 18th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2. class dbtable
  3. {
  4.  
  5. function __construct()
  6. {
  7. //$this->dbhost = 'localhost';
  8. //$this->dbuser = 'root';
  9. //$this->dbname = 'iams';
  10. //$this->dbpass = '';
  11. //$this->dbusertable = 'users';
  12. //session_start();
  13.  
  14. }
  15. function passresult($result)
  16. {
  17. $this->result=$result;
  18. $this->numofrow=mysql_num_rows($this->result);
  19. $this->numofcol=mysql_num_fields($this->result);
  20. }
  21. function htmltable()
  22. {
  23. if (($this->numofrow)>0)
  24.     {
  25.     echo '<table border=1>';
  26.     echo '<tr>';
  27.         foreach ($row1=mysql_fetch_assoc($this->result) as $key=>$value)
  28.         {
  29.             echo '<th>'.$key.'</th>';
  30.         }
  31.     echo '</tr>';
  32.     while($row=mysql_fetch_array($this->result))
  33.     //for($j=0; $j<($this->numofrow); $j++)
  34.     {   var_dump($row);
  35.         echo '<tr>';
  36.         for($i=0; $i<($this->numofcol); $i++)
  37.         {
  38.             echo '<td>'.$row[$i].'</td>';
  39.         }
  40.         echo '</tr>';
  41.  
  42.     }
  43.     echo '</table>';
  44.     }
  45. else {echo "No Data is there in supplied argument";}
  46. }
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement