Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/projects/quiz/

access-deneid.png
diagramresultat.php
insert-admin.php
login.php
logout.php
personliga-resultat.php
quiz-sida.php
ransa-quiz-session.php
ransa-skapa-quiz-session.php
resultat.php
session-variabler-unset.php
signin.php
skapa-inloggning-tabell.php
skapa-quiz-tabeller.php
skapa-quiz.php
start.php
tabort-kunder-quiz.php
åtkomst-nekad.php

personliga-resultat.php

50 lines UTF-8 Windows (CRLF)
<?php
  session_start
()

?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <?php
  
include ('../../dbconnection.php');

  
$quizIdLista = array();
  
$quizNamnLista = array();
  
$kundid $_SESSION["userId"];
  
$resultatQuizIdLista = array();
  
$antalRättLista = array();

  echo 
"<h1> Ditt bästa resultat i utförda Quiz </h1>";
  
$sql "SELECT * FROM quizer";
  
$stmt $dbconn->prepare($sql);
  
$data = array();  
  
$stmt->execute($data);
  while (
$res $stmt->fetch(PDO::FETCH_ASSOC)) {
    
array_push($quizIdLista$res['id']);
    
array_push($quizNamnLista$res['namn']);
  }

  
$sql "SELECT * FROM resultat where kundid = $kundid ORDER BY quizid ASC";
  
$stmt $dbconn->prepare($sql);
  
$data = array();  
  
$stmt->execute($data);
  while (
$res $stmt->fetch(PDO::FETCH_ASSOC)) {
    
array_push($resultatQuizIdLista$res['quizid']);
    
array_push($antalRättLista$res['antalrätt']);
  }


  for (
$i=0$i count($resultatQuizIdLista); $i++){
    echo 
"Bästa resultat i Quiz "$quizNamnLista[$i]. ": " .$antalRättLista[$i]. " av 5<br> <br>";
  }
  
?>
  <a href="start.php">Tillbaka till start</a>
</body>
</html>