Guest User

db3

a guest
Oct 5th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. $servername ="localhost";
  3. $username="root";
  4. $password="jit123";
  5. $dbname="1jt14cs007db3";
  6.  
  7. $conn= new mysqli($servername,$username,$password,$dbname);
  8.  
  9. if($conn->connection_error)
  10.     {
  11.         die("CONN failed :" . $conn->connect_error);
  12.     }
  13. else
  14.     {
  15.         $sqlquery="select * from student";
  16.         $result = $conn->query($sqlquery);
  17.         if($result->num_rows>0)
  18.         {echo "<table align=\"center\"border=1> <tr> <th> REG num </th> <th>STUDENT name</th><th>MAJOR</th><th>DOB</th></tr>";
  19.             while($row=$result->fetch_assoc())
  20.             {
  21.                
  22.                 echo "<tr><td>$row[regno]</td><td>$row[name]</td><td>$row[major]</td><td>$row[dob]</td></tr>";
  23.                
  24.             }
  25.             echo "</table>";
  26.         }
  27.         else echo "empty set";
  28.        
  29.     }
  30.    
  31.  
  32. $conn->close();
  33. ?>
Add Comment
Please, Sign In to add comment