Advertisement
adamec

sql

Jan 21st, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2. $host= "localhost";
  3. $conn = mysqli_connect($host,"root","");
  4.  
  5. if(!$conn) die("Nem lehet kapcsolódni!");
  6.  
  7. $adatbazis="munkahely";
  8. mysqli_select_db($conn,"$adatbazis") or die("Nem lehet megnyitni az adatbázist!".mysql_error());
  9.  
  10. $sql_query = "SELECT * FROM dolgozo";
  11. $sor=mysqli_query($conn,$sql_query,);
  12.  
  13. print "<table border=1>";
  14. print "<tr>";
  15. for($i=0;$i<6;$i++)
  16. {
  17.     print "<td>".$fieldName = mysqli_fetch_field_direct($sor, $i)->name;
  18. }
  19.     while($row=mysqli_fetch_object($sor))
  20.     {
  21.         print "<tr>";
  22.         foreach($row as $ertek)
  23.         {
  24.             print "<td> $ertek </td>";
  25.         }
  26.         print "</tr>";
  27.     }
  28.     print "</table>";
  29.     mysqli_close($conn);
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement