Advertisement
Guest User

Untitled

a guest
Apr 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <?php
  2. $host = '127.0.0.1';
  3. $db = 'pks';
  4. $user = 'root';
  5. $password = '';
  6. $charset = 'utf8';
  7. $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
  8. $opt = [
  9. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  10. PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  11. PDO::ATTR_EMULATE_PREPARES => false,
  12. ];
  13. $dbh = new PDO($dsn, $user, $password, $opt);
  14. $sql = $dbh->prepare("SELECT id_user,surname, name, id_user FROM user");
  15. $sql_Lab = $dbh->prepare("SELECT id_laboratory FROM laboratory");
  16. $result = array();
  17. /*while($row = $sql->fetch(PDO::FETCH_ASSOC)){
  18. var_dump($row);
  19. $row['surname'];
  20. $row['name'];
  21. }*/
  22.  
  23. ?>
  24.  
  25. <html>
  26. <head>
  27. <link rel="stylesheet" href="style.css" type="text/css"/>
  28. </head>
  29. <body>
  30. <table style="border:2px solid black">
  31. <tr>
  32. <td> <p> Oceny </p> </td>
  33. </tr>
  34. <tr>
  35. <td> Nazwa laboratorium </td>
  36. <td> Maksymalne punkty</td>
  37. </tr>
  38. <tr>
  39. <td> Nazwisko </td>
  40. <td> ImiÄ™ </td>
  41. <td> Punkty </td>
  42. </tr>
  43. <?php
  44. $sql_Lab->execute();
  45. $laboratory = ['id_laboratory'];
  46.  
  47. $userId ='';
  48. $points = '';
  49. $user = $userId;
  50. if($sql->execute()){
  51. while($row = $sql->fetch(PDO::FETCH_ASSOC)){
  52. $userId = $row['id_user'];
  53. ?>
  54. <tr>
  55. <td><?=$row['surname']?></td>
  56. <td><?=$row['name']?></td>
  57. <form action = "marks5.php?id_laboratory = 2" method = "get" id = "form1">
  58. <td>
  59. <input type="text" name="points" value = "<?=$points ? $points :'' ?>"/>
  60. </td>
  61. <td><input type="submit" value="Send"></td>
  62. </form>
  63. </tr>
  64. <?php
  65. }?>
  66.  
  67. <?php
  68. }
  69. ?>
  70. <?php
  71.  
  72. if($points){
  73. $ins = $dbh->prepare("INSERT INTO points(points, `user`,laboratory) VALUES (points=:points, `user`=:usr, laboratory=:laboratory)");
  74. $ins->bindParam(':points', $points);
  75. $ins->bindParam(':usr', $user);
  76. $ins->bindParam(':laboratory', $id_laboratory);
  77.  
  78. if($ins->execute()){
  79.  
  80. echo $points;
  81. echo $user;
  82. echo $laboratory;
  83. }else{
  84.  
  85. }
  86. }
  87. ?>
  88. </table>
  89.  
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement