Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $username = "phpdood";
  4. $password = "PopenHsesameP";
  5. $database = "kj_database2";
  6. mysql_connect($host,$username,$password);
  7. @mysql_select_db($database) or die("Unable to select database: ". mysql_error());
  8. $query  = "SELECT * FROM kj_datatable2";
  9. $result = mysql_query($query);
  10. $num = mysql_numrows($result);
  11. $i=0;
  12. ?>
  13. <html>
  14.         <body>
  15.                 <h4>DATA TABLE:</h4>
  16.                         <table border="5">
  17.         <tr>
  18.                 <th>Name</th> <th>Age</th> <th>Eye Colour</th> <th>Height</th> <th>Weight</th>
  19.         </tr>
  20.     <tr>
  21.  
  22. <?php
  23. while ($i < $num) {
  24.     $name=mysql_result($result,$i,"name");
  25.     $age=mysql_result($result,$i,"age");
  26.     $eyecolour=mysql_result($result,$i,"eye_colour");
  27.     $height=mysql_result($result,$i,"height");
  28.     $weight=mysql_result($result,$i,"weight");
  29. ?>
  30.                
  31.  
  32.                 <td><?php print "$name"; ?><td>
  33.                 <td><?php print "$age"; ?></td>
  34.                 <td><?php print "$eyecolour"; ?></td>
  35.                 <td><?php print "$height"; ?></td>
  36.                 <td><?php print "$weight"; ?></td>
  37.  
  38. <?php
  39. $i++;
  40. }
  41. ?>
  42.        </tr>
  43.     </table>
  44.   </body>
  45. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement