-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeckoptions.php
73 lines (57 loc) · 2.18 KB
/
deckoptions.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php require("inc/cookiecheck.inc"); ?>
<!DOCTYPE html>
<html>
<head>
<title>Your Decks</title>
<link type="text/css" rel="stylesheet" href="css/reset.css"/>
<link type="text/css" rel="stylesheet" href="css/main.css"/>
<script src="js/jquery-2.0.3.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/common.js"></script>
<script src="js/deckoptions.js"></script>
</head>
<body>
<?php require("header.php"); ?>
Your decks:<br>
<table id="tbl-deck-select">
<tr><th><input type="checkbox" name="select-all" id="select-all"/></th>
<th>Deck Name</th><th>Cards</th></tr>
<?php
require("inc/dbinfo.inc");
$userid = $_COOKIE['userid'];
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("
SELECT decks.deckid,name,count(*) AS cards
FROM decks JOIN flashcards ON decks.deckid = flashcards.deckid
WHERE userid=?
GROUP BY decks.deckid
");
$stmt->execute(array($userid));
// set the resulting array to associative
$stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach( $stmt->fetchall() as $rrow ){
echo '
<tr>
<td><input type="checkbox" name="deckid" value="'.$rrow['deckid'].'""/></td>
<td><a href="viewcards.php?deckid='.$rrow['deckid'].'">'.$rrow['name'].'</a></td>
<td>'.$rrow['cards'].'</td>
</tr>
';
}
}catch(PDOException $e){
echo "Error: " . $e->getMessage();
}
$conn = null;
foreach($_GET as $k=>$v){
echo '<input type="hidden" name="'.$k.'" value="'.$v.'" />';
}
?>
</table><br>
<input id="btn-delete" type="button" name="delete" value="Delete"/>
<input id="btn-combine" type="button" name="combine" value="Combine"/>
<input id="btn-copy" type="button" name="comp" value="Copy"/>
<br>
<?php require("footer.php"); ?>
</body>