Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = '127.0.0.1';
- $db = 'pks';
- $user = 'root';
- $password = '';
- $charset = 'utf8';
- $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
- $opt = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::ATTR_EMULATE_PREPARES => false,
- ];
- $dbh = new PDO($dsn, $user, $password, $opt);
- $sql = $dbh->prepare("SELECT id_user,surname, name, id_user FROM user");
- $sql_Lab = $dbh->prepare("SELECT id_laboratory FROM laboratory");
- $result = array();
- /*while($row = $sql->fetch(PDO::FETCH_ASSOC)){
- var_dump($row);
- $row['surname'];
- $row['name'];
- }*/
- ?>
- <html>
- <head>
- <link rel="stylesheet" href="style.css" type="text/css"/>
- </head>
- <body>
- <table style="border:2px solid black">
- <tr>
- <td> <p> Oceny </p> </td>
- </tr>
- <tr>
- <td> Nazwa laboratorium </td>
- <td> Maksymalne punkty</td>
- </tr>
- <tr>
- <td> Nazwisko </td>
- <td> ImiÄ™ </td>
- <td> Punkty </td>
- </tr>
- <?php
- $sql_Lab->execute();
- $laboratory = ['id_laboratory'];
- $userId ='';
- $points = '';
- $user = $userId;
- if($sql->execute()){
- while($row = $sql->fetch(PDO::FETCH_ASSOC)){
- $userId = $row['id_user'];
- ?>
- <tr>
- <td><?=$row['surname']?></td>
- <td><?=$row['name']?></td>
- <form action = "marks5.php?id_laboratory = 2" method = "get" id = "form1">
- <td>
- <input type="text" name="points" value = "<?=$points ? $points :'' ?>"/>
- </td>
- <td><input type="submit" value="Send"></td>
- </form>
- </tr>
- <?php
- }?>
- <?php
- }
- ?>
- <?php
- if($points){
- $ins = $dbh->prepare("INSERT INTO points(points, `user`,laboratory) VALUES (points=:points, `user`=:usr, laboratory=:laboratory)");
- $ins->bindParam(':points', $points);
- $ins->bindParam(':usr', $user);
- $ins->bindParam(':laboratory', $id_laboratory);
- if($ins->execute()){
- echo $points;
- echo $user;
- echo $laboratory;
- }else{
- }
- }
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement