Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "trabalho_final";
  6. $cookie = $_COOKIE['login'];
  7. if (isset($cookie)) {
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14.  
  15. $sql = "SELECT * FROM cadastrar_alunos";
  16. $result = $conn->query($sql);
  17. function display_data($data) {
  18. $output = "<table>";
  19. foreach($data as $key => $var) {
  20. //$output .= '<tr>';
  21. if($key===0) {
  22. $output .= '<tr>';
  23. foreach($var as $col => $val) {
  24. $output .= "<td>" . $col . '</td>';
  25. }
  26. $output .= '</tr>';
  27. foreach($var as $col => $val) {
  28. $output .= '<td>' . $val . '</td>';
  29. }
  30. $output .= '</tr>';
  31. }
  32. else {
  33. $output .= '<tr>';
  34. foreach($var as $col => $val) {
  35. $output .= '<td>' . $val . '</td>';
  36. }
  37. $output .= '</tr>';
  38. }
  39. }
  40. $output .= '</table>';
  41. echo $output;
  42. }
  43. display_data($result);
  44.  
  45. $conn->close();
  46. }else{
  47. echo"Faรงa login primeiro!";
  48. }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement