Show sourcecode
The following files exists in this folder. Click to view.
webbsrvprg/exercises/ajax/ajax/
ajax.php
ajaxClient.php
ajaxService.php
createtable.php
insert.php
ajaxService.php
35 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
if (isset($_GET["name"])) {
/** @var PDO $dbconn */
include "../../../dbconnection.php";
try {
$sql = "SELECT * FROM ajaxtest WHERE name LIKE ?";
$stmt = $dbconn->prepare($sql);
$data = array($_GET["name"] . "%");
$stmt->execute($data);
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = $res["name"];
$points = $res["points"];
echo "$name - $points Poäng<br>";
}
}
catch (PDOException $e) {
echo $e;
}
}
?>
</body>
</html>