-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecipes.php
147 lines (137 loc) · 5.1 KB
/
recipes.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php require_once('Connections/munchies1.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recipes = 20;
$pageNum_Recipes = 0;
if (isset($_GET['pageNum_Recipes'])) {
$pageNum_Recipes = $_GET['pageNum_Recipes'];
}
$startRow_Recipes = $pageNum_Recipes * $maxRows_Recipes;
$sort="ep DESC";
if($_GET["sort"]=="name") $sort="name ASC";
mysql_select_db($database_munchies1, $munchies1);
$query_Recipes = "SELECT num, name, ep FROM recipes ORDER BY ".$sort;
$query_limit_Recipes = sprintf("%s LIMIT %d, %d", $query_Recipes, $startRow_Recipes, $maxRows_Recipes);
$Recipes = mysql_query($query_limit_Recipes, $munchies1) or die(mysql_error());
$row_Recipes = mysql_fetch_assoc($Recipes);
if (isset($_GET['totalRows_Recipes'])) {
$totalRows_Recipes = $_GET['totalRows_Recipes'];
} else {
$all_Recipes = mysql_query($query_Recipes);
$totalRows_Recipes = mysql_num_rows($all_Recipes);
}
$totalPages_Recipes = ceil($totalRows_Recipes/$maxRows_Recipes)-1;
$queryString_Recipes = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recipes") == false &&
stristr($param, "totalRows_Recipes") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recipes = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recipes = sprintf("&totalRows_Recipes=%d%s", $totalRows_Recipes, $queryString_Recipes);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Recipes</title>
<link href="Styles/general.css" rel="stylesheet" type="text/css" />
<!--[if lt IE 7.]>
<script defer type="text/javascript" src="scripts/pngfix.js"></script>
<![endif]-->
<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=575,height=350');");
}
</script>
<style type="text/css">
<!--
.rlist {
margin: 20px;
border: 4px solid #000000;
background-color: #FFFFB7;
color: #8C0000;
width: 600px;
}
.rlisth {
color: #FFFFB7;
background-color: #8C0000;
}
.rlist a {
color: #8C0000;
}
.rlist .rlisth a {
color: #FFFFB7;
}
.rlist td {
border: 1px dotted #8C0000;
}
-->
</style>
</head>
<body>
<div align="center">
<div id="stuff">
<div id="main">
<div align="center"><img src="media/graphics/book-flat.gif" alt="Episode Guide" width="500" height="121" /></div>
<table align="center" class="rlist">
<tr class="rlisth">
<td><?php if($_GET["sort"]!="name"){ ?><a href="recipes.php?sort=name">Recipe</a><?php } else { echo "Recipe"; } ?></td>
<td width="65">
<div align="center">
<?php if(isset($_GET["sort"])){ ?>
<a href="recipes.php">Episode</a>
<?php } else { echo "Episode"; } ?>
</div></td>
</tr>
<?php do { ?>
<tr>
<td><a href="javascript:popUp('recipe-card.php?num=<?php echo $row_Recipes['num']; ?>')"><?php echo $row_Recipes['name']; ?></a></td>
<td width="65"><div align="right"><?php echo $row_Recipes['ep']; ?></div></td>
</tr>
<?php } while ($row_Recipes = mysql_fetch_assoc($Recipes)); ?>
</table>
<div align="center" style="height:29px; margin-top:15px; overflow:hidden;">
<div style="width:490px">
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recipes > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recipes=%d%s", $currentPage, 0, $queryString_Recipes); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_Recipes > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recipes=%d%s", $currentPage, max(0, $pageNum_Recipes - 1), $queryString_Recipes); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recipes < $totalPages_Recipes) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recipes=%d%s", $currentPage, min($totalPages_Recipes, $pageNum_Recipes + 1), $queryString_Recipes); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_Recipes < $totalPages_Recipes) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recipes=%d%s", $currentPage, $totalPages_Recipes, $queryString_Recipes); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="sidebar">
<a href="/"><img src="media/graphics/minifridge.gif" alt="home" width="100" height="188" border="0" /></a>
</div>
<?php readfile('footer.php'); ?>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($Recipes);
?>