Practical Assessment – Personal Watercraft Licence
Safety on a Jetski
Photo Gallery
db_connect();
if ($limit==0 or $limit=="")
$limit=12;
if ($MMBuyGroups == "") $MMBuyGroups=1;
$adjacents = 3;
if (!isset($cat)) $cat=addslashes($_GET['cat']);
/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
if ($action=="Search"){
$query = "SELECT COUNT(*) as num FROM products WHERE (itemname LIKE '%$searchfor%' or itemcode LIKE '%$searchfor%' or itemdesc LIKE '%$searchfor%' or itemdesc2 LIKE '%$searchfor%' or itemdesc3 LIKE '%$searchfor%' or itemdesc4 LIKE '%$searchfor%' or itemdesc5 LIKE '%$searchfor%' or keywords LIKE '%$searchfor%') and itemcat != '1'";
$extraparams="&searchfor=$searchfor";
}
elseif ($action=="Specials")
$query="SELECT COUNT(*) as num FROM products WHERE specialproduct='Yes'";
elseif ($action=="NewProducts")
$query="SELECT COUNT(*) as num FROM products WHERE newproduct='Yes'";
else
$query="SELECT COUNT(*) as num FROM products WHERE itemcat='$cat' or itemcat2='$cat' or itemcat3='$cat' or itemcat4='$cat' or itemcat5='$cat'";
$total_pages = mysqli_fetch_array($conn->query($query));
$total_pages = $total_pages[num];
/* Setup vars for query. */
$targetpage = $_SERVER['PHP_SELF']; //your file name (the name of this file)
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Get data. */
if ($action=="Search") {
$sql = "SELECT * FROM products WHERE (itemname LIKE '%$searchfor%' or itemcode LIKE '%$searchfor%' or itemdesc LIKE '%$searchfor%' or itemdesc2 LIKE '%$searchfor%' or itemdesc3 LIKE '%$searchfor%' or itemdesc4 LIKE '%$searchfor%' or itemdesc5 LIKE '%$searchfor%' or keywords LIKE '%$searchfor%') and itemcat != '1' LIMIT $start, $limit";
$extraparams="&searchfor=$searchfor";
}
elseif ($action=="Specials")
$sql="SELECT * FROM products WHERE specialproduct='Yes' ORDER BY itemname LIMIT $start, $limit";
elseif ($action=="NewProducts")
$sql="SELECT * FROM products WHERE newproduct='Yes' ORDER BY itemname LIMIT $start, $limit";
else
$sql="SELECT * FROM products WHERE itemcat='$cat' or itemcat2='$cat' or itemcat3='$cat' or itemcat4='$cat' or itemcat5='$cat' ORDER BY priority,itemname LIMIT $start, $limit";
$CatResult = $conn->query($sql);
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
if ($_GET['Test']=="Yes") echo "SQL: $sql ";
$pagination = "";
if($lastpage > 1){
$pagination1 .= "
\n
\n";
$pagination1 .= "
Pages:
\n";
//previous button
//if ($page > 1)
// $pagination1.= "Prev | ";
//else
// $pagination1.= "Prev | ";
if ($lastpage < 7 + ($adjacents * 2)) { //not enough pages to bother breaking it up
for ($counter = 1; $counter <= $lastpage; $counter++) {
if ($counter == $page)
$pagination1.= "
\n";
}
else {
if ($CatHeading and $DisplayPageHeader != "No") echo "
$CatHeading
\n";
elseif ($CategoryName and $DisplayPageHeader != "No") echo "
$CategoryName
\n";
}
echo $BodyText;
echo "
\n"; // Close CategoryText
if (!isset($cat)) $cat=$_GET['cat'];
$sql="SELECT * FROM products WHERE itemcat='$cat' or itemcat2='$cat' or itemcat3='$cat' or itemcat4='$cat' or itemcat5='$cat' ORDER BY priority,itemname LIMIT $start, $limit";
}
db_connect();
$CatResult = $conn->query($sql)
or die("Cannot execute query\n");
$rows = mysqli_num_rows($CatResult);
if (mysqli_num_rows($CatResult)== 0)
echo"