-
Notifications
You must be signed in to change notification settings - Fork 6
/
quizz.php
47 lines (37 loc) · 1.2 KB
/
quizz.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// session_start();
require 'connection.php';
$success=0;
try {
$conn = new PDO("mysql:host=$servername;dbname=ican", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql="Select * from quiz_types";
$result = $conn->prepare($sql);
$result->execute();
$final_results = $result->fetchAll(PDO::FETCH_ASSOC);
$success=1;
$i=0;
?>
<div class="l12 m12 s12 x12 xs12">
<?php
foreach ($final_results as $key => $quiz_types) { ?>
<div class="l3 m3 s3 x12 xs12 center-block light-magenta" id="<?php echo $quiz_types['quiz_name']; ?>">
<a href='quiz_details.php?id=<?php echo $quiz_types['id'];?>' id="<?php echo $quiz_types['id'];?>">
<img src="images/<?php echo $quiz_types['quiz_image'];?>" class="quiz_image" alt="alt_text">
</a>
<h4><?php echo $quiz_types['quiz_name']; $i++; ?> </h4></div>
<?php
if($i%4==0){
echo "</div>";
echo "<div class='l12 m12 s12 x12 xs12'>";
}
}
?>
</div>
<?php
}
catch(PDOException $e){
$success=0;
$message= "Connection failed: " . $e->getMessage();
}
?>