Advertisement
crDahaka

Untitled

Nov 17th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. class Table extends Grid {
  6.  
  7.  
  8.     public function render(){
  9.  
  10.         echo "
  11.            <table>
  12.                 <tr>
  13.                    <th>Id</th>
  14.                    <th>Title</th>
  15.                    <th>Link</th>
  16.                </tr>
  17.        ";
  18.         $this->getData();
  19.     }
  20.  
  21.     public function getData(){
  22.         $db_host = "localhost";
  23.         $db_name = "dbpaging";
  24.         $db_user = "root";
  25.         $db_pass = "";
  26.  
  27.         $db = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
  28.         $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  29.        
  30.         $users = $db->query("SELECT * FROM tbl_tutorials");
  31.  
  32.         foreach ($users as $user) {
  33.  
  34.             $tuts_id = $user['tuts_id'];
  35.             $tuts_title = $user['tuts_title'];
  36.             $tuts_link = $user['tuts_link'];
  37.  
  38.             echo"
  39.                <tr>
  40.                    <td>$tuts_id</td>
  41.                    <td>$tuts_title</td>
  42.                    <td>$tuts_link</td>
  43.                </tr>
  44.                
  45.            ";
  46.         }
  47.        
  48.     }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement