Greetings to all I first time here
I have a problem with the script
when I’m on page category.html evrithing is OK but when I click on page nation next to see next url on category.php?pn=2 it is show error
Notice: Undefined index: category in D:\xampp\htdocs\13\includes\getCategoryCovers.php on line 2
Notice: Undefined variable: cat_name in D:\xampp\htdocs\13\includes\getCategoryCovers.php on line 100
Notice: Undefined variable: Category_post in D:\xampp\htdocs\13\includes\getCategoryCovers.php on line 101
[php]<?php
$get_cat = $_GET[‘category’];
///Select Category
$get_category = mysql_query("SELECT * FROM covers_categories WHERE category_slug = '$get_cat' ");
$category_exists = mysql_num_rows($get_category);
if($category_exists == '0'){
redirect('404.php', '0');
}else{
$catrow = mysql_fetch_assoc($get_category);
$get_cat = $catrow['category_id'];
$cat_name = $catrow['category_name'];
}
///Get All Covers///
$covers_posts = mysql_query("SELECT * FROM covers_posts WHERE post_category = '$get_cat' AND post_approve = '1' ");
$total_covers_Category = mysql_num_rows($covers_posts);
if (isset($_GET['pn'])) { // Get pn from URL vars if it is present
$pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); // filter everything but numbers for security(new)
} else { // If the pn URL variable is not present force it to be value of page number 1
$pn = 1;
}
$itemsPerPage = 20;
$lastPage = ceil($total_covers_Category / $itemsPerPage);
if ($pn < 1) { // If it is less than 1
$pn = 1; // force if to be 1
} else if ($pn > $lastPage) { // if it is greater than $lastpage
$pn = $lastPage; // force it to be $lastpage's value
}
// This creates the numbers to click in between the next and back buttons
// This section is explained well in the video that accompanies this script
$centerPages = “”;
$sub1 = $pn - 1;
$sub2 = $pn - 2;
$add1 = $pn + 1;
$add2 = $pn + 2;
if ($pn == 1) {
$centerPages .= ’
$centerPages .= ’
} else if ($pn == $lastPage) {
$centerPages .= ’
$centerPages .= ’
} else if ($pn > 2 && $pn < ($lastPage - 1)) {
$centerPages .= ’
$centerPages .= ’
$centerPages .= ’
$centerPages .= ’
$centerPages .= ’
} else if ($pn > 1 && $pn < $lastPage) {
$centerPages .= ’
$centerPages .= ’
$centerPages .= ’
}
// This line sets the “LIMIT” range… the 2 values we place to choose a range of rows from database in our query
$limit = ‘LIMIT ’ .($pn - 1) * $itemsPerPage .’,’ .$itemsPerPage;
// Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax
// $sql2 is what we will use to fuel our while loop statement below
$sql2 = mysql_query(“SELECT * FROM covers_posts WHERE post_category = ‘$get_cat’ AND post_approve = ‘1’ $limit”);
//////////////////////////////// END Adam’s Pagination Logic ////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Adam’s Pagination Display Setup /////////////////////////////////////////////////////////////////////
$paginationDisplay = “”; // Initialize the pagination output variable
// This code runs only if the last page variable is ot equal to 1, if it is only 1 page we require no paginated links to display
if ($lastPage != “1”){
// This shows the user what page they are on, and the total number of pages
// If we are not on page 1 we can place the Back button
$paginationDisplay .= ‘
’;
if ($pn != 1) {
$previous = $pn - 1;
$paginationDisplay .= ’ Back ';
}
$paginationDisplay .= ‘
if ($pn != 1) {
$previous = $pn - 1;
$paginationDisplay .= ’ Back ';
}
$paginationDisplay .= ‘
- ’;
// Lay in the clickable numbers display here between the Back and Next links
$paginationDisplay .= $centerPages;
$paginationDisplay .= ‘
// If we are not on the very last page we can place the Next button
if ($pn != $lastPage) {
$nextPage = $pn + 1;
$paginationDisplay .= '<a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '" class="btn btn-danger next"> Next <i class="fui-arrow-right"></i></a> ';
}
$paginationDisplay .= ' Page <strong>' . $pn . '</strong> of ' . $lastPage. ' ';
$paginationDisplay .= '</div>';
}
//print_r($covers_posts);
if ($total_covers_Category != 0) {
while ( $covers_post = mysql_fetch_assoc($sql2) ) {
$Category_post[] = $covers_post;
}
}
$span = 'span5';
$smarty->assign('span', $span);
$smarty->assign('TotalCategoryCovers', $total_covers_Category);
$smarty->assign('CategoryName', $cat_name);
$smarty->assign('CategoryCovers', $Category_post);
$smarty->assign('PaginationCategory', $paginationDisplay);[/php]