how to convert MySQL to MySQLi with PHP and jQuery.
If I run the file below using MySQL work but I want to use MySQLi, how to change it?
cek my file:
pagination_class.php
<?php class Pagination_class
{
var $result;
var $anchors;
var $total;
function Pagination_class($qry,$starting,$recpage)
{
$rst = mysql_query($qry) or die(mysql_error());
$numrows = mysql_num_rows($rst);
$qry .= " limit $starting, $recpage";
$this->result = mysql_query($qry) or die(mysql_error());
$next = $starting+$recpage;
$var = ((intval($numrows/$recpage))-1)*$recpage;
$page_showing = intval($starting/$recpage)+1;
$total_page = ceil($numrows/$recpage);
if($numrows % $recpage != 0)
{
$last = ((intval($numrows/$recpage)))*$recpage;
}
else
{
$last = ((intval($numrows/$recpage))-1)*$recpage;
}
$previous = $starting-$recpage;
$anc = "<ul class='pagination m_bottom_0 f_top_5'>";
if($previous < 0)
{
$anc .= "<li class='disabled'>
<a href='javascript:;'>
<i class='mdw-icon fa fa-angle-left'></i>
</a>
</li>";
}
else
{
$anc .= "<li>
<a href='javascript:pagination($previous);'>
<i class='mdw-icon fa fa-angle-left'></i>
</a>
</li>";
}
$norepeat = 2;
$j = 2;
$anch = "";
for($i=$page_showing; $i>1; $i--)
{
$fpreviousPage = $i-1;
$page = ceil($fpreviousPage*$recpage)-$recpage;
$anch = "<li><a href='javascript:pagination($page);'>$fpreviousPage </a></li>".$anch;
if($j == $norepeat) break;
$j++;
}
$anc .= $anch;
$anc .= "<li class='active'><a href='javascript:;'>".$page_showing."</a></li>";
$j = 1;
for($i=$page_showing; $i<$total_page; $i++)
{
$fnextPage = $i+1;
$page = ceil($fnextPage*$recpage)-$recpage;
$anc .= "<li><a href='javascript:pagination($page);'>$fnextPage</a></li>";
if($j==$norepeat) break;
$j++;
}
if($next >= $numrows)
{
$anc .= "<li class='disabled'>
<a href='javascript:;'>
<i class='mdw-icon fa fa-angle-right'></i>
</a>
</li>";
}
else
{
$anc .= "<li>
<a href='javascript:pagination($next);'>
<i class='mdw-icon fa fa-angle-right'></i>
</a>
</li>";
}
$anc .= "</ul>";
$this->anchors = $anc;
$this->total = "<div>Halaman : <strong>$page_showing</strong> dari <strong>$total_page</strong>. Total : <strong>$numrows</strong> records</div>";
}
} ?>
and below file berita_view
please check in pastebin
Thanks.
Related
So I have these two PHP files products.php and receive.php .
What my problem is I want to use Ajax on displaying the products with search and paginates also. The code below works though but only if I use a GET. Is it possible to submit only the page number and refreshes only the div (where products loop) and not the whole page so that my POST requests (from search values - title, keywords) will still hold? coz if I use GET on pagination, the POST requests are getting empty after clicking the second page.
receive.php
$pdo_sql = 'SELECT * FROM items WHERE item_title LIKE %$keyword% OR keywords LIKE %$keyword% ORDER BY id DESC ';
/*** Pagination Code starts ***/
$per_page_html = '';
$page = 1;
$start=0;
// Get Page Number
if(!empty($_GET["page"])) {
$page = $_GET["page"];
$start=($page-1) * ROW_PER_PAGE;
}
// Adds Limit to Query then Execute
$limit=" LIMIT " . $start . "," . ROW_PER_PAGE;
$pagination_statement = $pdo_conn->prepare($pdo_sql);
$pagination_statement->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR);
$pagination_statement->execute();
// Count the total number of rows
$row_count = $pagination_statement->rowCount();
if(!empty($row_count)){
$total_links=ceil($row_count/ROW_PER_PAGE);
$previous_link = $next_link = $page_link = '';
if($total_links > 4)
{
if($page < 5)
{
for($count = 1; $count <= 5; $count++)
{
$page_array[] = $count;
}
$page_array[] = '...';
$page_array[] = $total_links;
}
else
{
$end_limit = $total_links - 5;
if($page > $end_limit)
{
$page_array[] = 1;
$page_array[] = '...';
for($count = $end_limit; $count <= $total_links; $count++)
{
$page_array[] = $count;
}
}
else
{
$page_array[] = 1;
$page_array[] = '...';
for($count = $page - 1; $count <= $page + 1; $count++)
{
$page_array[] = $count;
}
$page_array[] = '...';
$page_array[] = $total_links;
}
}
}
else
{
for($count = 1; $count <= $total_links; $count++)
{
$page_array[] = $count;
}
}
for($count = 0; $count < count($page_array); $count++)
{
if($page == $page_array[$count])
{
// Current Page = Selected Page
$page_link .= '<a class="paginate_current" href="javascript:void(0)">'.$page_array[$count].'</a>';
$previous_id = $page_array[$count] - 1;
if($previous_id > 0)
{
// Previous Button Enable
$previous_link = '<a class="paginate_prev" href="products.php?page='.$previous_id.'">Previous</a>';
}
else
{
// Previous Button Disabled
$previous_link = '<a class="paginate_prev-disabled" href="javascript:void(0)">Previous</a>';
}
$next_id = $page_array[$count] + 1;
if($next_id > $total_links)
{
// Next Button Disabled
$next_link = '<a class="paginate_next-disabled" href="javascript:void(0)">Next</a>';
}
else
{
// Next Button Enabled
$next_link = '<a class="paginate_next" href="products.php?page='.$next_id.'">Next</a>';
}
}
else
{
if($page_array[$count] == '...')
{
// Ellipsis
$page_link .= '<a class="paginate_ellipsis" href="javascript:void(0)">...</a>';
}
else
{
// Pages
$page_link .= '<a class="paginate_pages" href="products.php?page='.$page_array[$count].'">'.$page_array[$count].'</a>';
}
}
}
$per_page_html .= '<div class="text-center paginate">';
$per_page_html .= $previous_link . $page_link . $next_link;
$per_page_html .= '</div>';
}
$query = $pdo_sql.$limit;
$pdo_statement = $pdo_conn->prepare($query);
$pdo_statement->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR);
$pdo_statement->execute();
$pdo_result = $pdo_statement->fetchAll();
products.php
<div class="row">
<div class="col">
<div class="products_container grid" id="refresh">
<?php
if(!empty($pdo_result)) {
foreach($pdo_result as $pdo_row) {
$id = $pdo_row['id'];
$name = $pdo_row['item_title'];
$img = $pdo_row['item_img'];
$price = $pdo_row['item_price'];
$sold = $pdo_row['item_sold'];
$stocks = $pdo_row['stocks'];
$date = $pdo_row['date'];
if ($sold >= $max && $date != date("Y-m-d") ) {
$sort = 'hot';
}else if($date == date("Y-m-d") && $sold <= $max){
$sort = 'new';
}else{
$sort = '';
}
echo '
<div class="product grid-item '.$sort.'">
<div class="product_inner">
<div class="product_image">
<img src="'.$img.'" alt="">
<div class="product_tag">'.$sort.'</div>
</div>
<div class="product_content text-center">
<div class="product_title text-long">'.$name.'</div>
<div class="product_price">₱'.number_format($price).'</div>
<div class="product_button ml-auto mr-auto trans_200">
<button class="product_button ml-auto mr-auto trans_200" id="add2c" data-prod=" '.$id.' " type="button" >add to cart</button>
</div>
</div>
</div>
</div>
';
} //End Foreach Loop
}
else{
echo "no products found";
}
?>
</div>
</div>
</div>
<!-- PAGINATION HERE -->
<?php echo $per_page_html; ?>
Method 1 => Without ajax
You can use the GET method for search value also. and in every pagination link
append the search value too.
for example.
$next_link = '<a class="paginate_next" href="products.php?page='.$next_id.'">Next</a>';
instead of above line use below one.
$next_link = '<a class="paginate_next" href="products.php?page='.$next_id.'&search='.$keyword.'">Next</a>';
Method 2 => using ajax
instead of href use a javascript function like below
$next_link = '<a class="paginate_next" href="#" onclick="paginate_fn(\''.$next_id.'\', \''.$keyword.'\'">Next</a>'
<script>
function paginate_fn(pageID, keyword){
$.ajax({
async: true,
type: 'get', // you can use post also
dataType:'json',
data: {'pageID':pageID, 'keyword': keyword},
url: "paget_name.php", // your page name
success: function (data) {
$('#search-content').html( data['content'] );
},
error: function () {
alert('An Error Occurred!.');
}
});
}
</script>
I am trying to fetch members ratings from the database using ajax. I passed a function to the JSON, even though it returned a value in the function but it doesn't execute the for loop condition.
Here is my code, the loop failed to execute. What am I doing wrong?
function mrate($irate) {
$class = "fa-star star-filled";
for ($i = 0; $i < 5; $i++) {
if ($irate <= $i) {
$class = "fa-star-o empty";
}
return '<i class="fa ' . $class . '"></i>';
}
}
$perPage = 2;
if (isset($_GET["page"]) && isset($_GET["page"])) {
$page = $_GET["page"];
$pid = $mysqli->real_string_escape($_GET["pid"]);
} else {
$page = 1;
$pid = $mysqli->real_string_escape($_SESSION['pid']);
};
$startFrom = ($page - 1) * $perPage;
$sqlQuery = "SELECT id, name,
review, rating, added_date
FROM review_rating
where product_id = '$pid'
ORDER BY id ASC LIMIT $startFrom, $perPage";
$result = mysqli_query($mysqli, $sqlQuery);
$paginationHtml = '';
while ($row = mysqli_fetch_assoc($result)) {
$img = '<img class="rounded-circle" width="50" src="' . $set['installUrl'] . 'assets/img/login.png" alt="' . $row["name"] . '"/>';
$irate = $row['rating'];
$paginationHtml .= '<div class="product-review pb-4 mb-4 border-bottom">';
$paginationHtml .= '<div class="d-flex mb-3">';
$paginationHtml .= '<div class="media media-ie-fix align-items-center mr-4 pr-2">' . $img;
$paginationHtml .= '<div class="media-body pl-3"><h6 class="font-size-sm mb-0">' . $row["name"] . '</h6>';
$paginationHtml .= '<span class="font-size-ms text-muted">' . $row['added_date'] . '</span></div></div>';
$paginationHtml .= '<div><div class="star-rating">' . mrate($irate) . '</div></div>';
$paginationHtml .= '</div>';
$paginationHtml .= '<p class="font-size-md mb-2">' . $row['review'] . '</p>';
$paginationHtml .= '</div>';
}
$jsonData = array(
"html" => $paginationHtml,
);
echo json_encode($jsonData);
Replace your function mrate($irate) with this and try. You needed to concatenate the stars code to display it more than once.
function mrate($irate){
$stars = '';
for($i=0; $i<5; $i++){
if($irate <= $i){
$class = "fa-star-o empty";
}else{
$class = "fa-star star-filled";
}
$stars .= '<i class="fa '.$class.'"></i>';
}
return $stars;
}
Assuming there's no fractional rating, you can do the following - Display all 5 stars but solid ones will represent the rating.
function mrate($irate){
$class = '';
for($i = 0; $i < 5; $i++){
if ($irate <= $i) {
$class .= '<i class="fa fa-star"></i>';
} else {
$class .= '<i class="fa fa-star-o"></i>';
}
}
return $class;
}
I have problem error for load page 2,3,4 n etc of my original link is http://bali-webdesign.com/staging/astina3/subkategori-Bali%20Package-3-3.htm..
here my class_paging.php
class Paging{
function cariPosisi($batas){
if(empty($_GET['halaman'])){
$posisi=0;
$_GET['halaman']=1;
}
else{
$posisi = ($_GET['halaman']-1) * $batas;
}
return $posisi;
}
function jumlahHalaman($jmldata, $batas){
$jmlhalaman = ceil($jmldata/$batas);
return $jmlhalaman;
}
function navHalaman($halaman_aktif, $jmlhalaman){
$link_halaman = "";
// Link ke halaman pertama (first) dan sebelumnya (prev)
if($halaman_aktif > 1){
$prev = $halaman_aktif-1;
$link_halaman .= "<li class='paginate_button previous' id='table-gallery_previous'><a aria-controls='table-gallery' data-dt-idx='0' tabindex='0' href=$_SERVER[PHP_SELF]?halaman=1>«</a></li>
<li><a href=$_SERVER[PHP_SELF]?halaman=$prev>‹</a></li>";
}
else{
$link_halaman .= "<li class='disabled'><a>«</a></li><li class='disabled'><a>‹</a></li>";
}
// Link halaman 1,2,3, ...
$angka = ($halaman_aktif > 3 ? "" : " ");
for ($i=$halaman_aktif-2; $i<$halaman_aktif; $i++){
if ($i < 1)
continue;
$angka .= "<li><a href=$_SERVER[PHP_SELF]?halaman=$i>$i</a></li>";
}
$angka .= "<li class='paginate_button active'><a aria-controls='table-gallery' data-dt-idx='1' tabindex='0'>$halaman_aktif</a></li>";
for($i=$halaman_aktif+1; $i<($halaman_aktif+3); $i++){
if($i > $jmlhalaman)
break;
$angka .= "<li><a aria-controls='table-gallery' data-dt-idx='1' tabindex='0' href=$_SERVER[PHP_SELF]?halaman=$i>$i</a></li>";
}
$angka .= ($halaman_aktif+2<$jmlhalaman ? "<li><a href=$_SERVER[PHP_SELF]?halaman=$jmlhalaman>$jmlhalaman</a></li>" : " ");
$link_halaman .= "$angka";
// Link ke halaman berikutnya (Next) dan terakhir (Last)
if($halaman_aktif < $jmlhalaman){
$next = $halaman_aktif+1;
$link_halaman .= "<li class='paginate_button next' id='table-gallery_next'><a aria-controls='table-gallery' data-dt-idx='2' tabindex='0' href=$_SERVER[PHP_SELF]?halaman=$next>›</a></li><li><a href=$_SERVER[PHP_SELF]?halaman=$jmlhalaman>»</a></li>";
}
else{
$link_halaman .= "<li class='disabled'><a href='#'>›</a></li><li class='disabled'><a href='#'>»</a></li>";
}
return $link_halaman;
}
}
then in my page which I load pagination function
include "inc/config/class_paging.php";
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$s = new Paging;
$batas = 10;
$posisi = $s->cariPosisi($batas);
$produk = mysql_query("SELECT * FROM produk where id_subkategori='$_GET[idkk]' LIMIT $posisi,$batas");
$jmldata = mysql_num_rows(mysql_query("SELECT * FROM produk"));
while($p=mysql_fetch_array($produk)){
echo "blabla";
}
$jmlhalaman = $s->jumlahHalaman($jmldata, $batas);
$linkHalaman = $s->navHalaman($_GET[halaman], $jmlhalaman);
echo "<div align='center' class='dataTables_paginate paging_simple_numbers' id='table-about_paginate'>
<ul class='pagination'>$linkHalaman</ul>
</div>";
Right now, when I click page 2 button of pagination, the result link will be bali-webdesign.com/staging/astina3/subkategori.php?halaman=2 but that link can't show my data. I want when I click page 2 button of pagination will show my data
what should I change in class_paging.php for link url so it can show data on page 2,3,4 n etc
I'm trying to active class on list
Kindly if any one can help me to add class="active" on displayed pagination page:
$perpage= $conf['perpage'];
if (isset($_GET["page"])) {
$page = $_GET["page"];
} else {
$page=1;
};
$start_from = ($page-1) * $perpage;
$result = "SELECT * FROM topics LIMIT $start_from, $perpage";
$result = mysql_query ($result);
$n = 0;
while ($row = mysql_fetch_array ($result)){
echo '<tr>';
echo '<td>'.$row['topic_no'].'</td>';
echo '</tr>';
++$n;
}
$sql = "SELECT * FROM topics";
$result = mysql_query($sql);
$total_records = mysql_num_rows($result);
$total_pages = ceil($total_records / $perpage);
echo '<ul class="pagination">';
echo "<li><a href='topics.php?page=1'>".'<'."</a></li> ";
for ($i=1; $i<=$total_pages; $i++) {
echo "<li ><a href='topics.php?page=".$i."'>".$i."</a></li> ";
};
echo "<li><a href='topics.php?page=$total_pages'>".'>'."</a> </li>";
echo '</ul> ';
Thanks in Advance
You Can also try this code. it's working
$c="active";
for ($i=1; $i <$total_page ; $i++) {
if($page==$i)
{
$c="active";
}
else
{
$c="";
}
echo "<li class=\"$c\">$i</li>";
}
$active = $i == $page ? 'class="active"' : '';
echo "<li ><a {$active} href=\"topics.php?page={$i}\">{$i}</a></li> ";
We just need to add class="active" only if page is current, otherwise we add nothing. If you already have classes for rows - you just need to use smth like
$activeClass = $i == $page ? 'active' : '';
echo "<li ><a class=\"my-row-class1 {$activeClass}\" href=\"topics.php?page={$i}\">{$i}</a></li> ";
echo "<li if($_GET['page']==$i){ class='active'}><a href='topics.php?page=".$i."'>".$i."</a></li> ";
Please try this. It might help you
$search = #$_GET['page']; // get value form other page
$page ='A';
for ($Page=1; $Page <27 ; $Page++) { ?> // abcdef... create
<li class="<?php if($search==$page){ echo 'active'; } ?>"> <?php echo ''. $page++ . '' ;?> </li>
<?php } ?>
/* if($search==$page){ echo 'active'; } this code means if search value == alphabet then class active call automatically */
$today = date('D, d M, Y');
$sql = "SELECT * FROM table WHERE date = '$today'";
if ($_POST!="") {
$mydate = mysql_real_escape_string($_POST['datepicker']);
if ($mydate != "") {
$sql = "SELECT * FROM table WHERE date = '$mydate'";
}
}
$num_results_per_page = 8;
$num_page_links_per_page = 5;
$pg_param = "";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
pagination($sql, $num_results_per_page, $num_page_links_per_page, $pg_param);
if($pg_error == '')
{
if(mysql_num_rows($pg_result) > 0)
{
while($data = mysql_fetch_assoc($pg_result))
{
echo "";
}
echo "</br>". $pagination_output;
}
else
{
echo "No Data.";
}
}
else
{
echo $pg_error;
}
Pagination is working correctly for select $today. Here pagination is not taking value to second page in the case of select $mydate. If second page of $mydate clicks, again going to $today. ie Second click is not posting $mydate to next page. How can I take the value to second page?
pagination.php
$pg_error = '';
$pg_result = '';
$pagination_output = '';
$max_pages = '';
$page_id = '';
$page_numbers_per_page = '';
$pg_user_param = '';
function pagination($sql, $num_results_per_page, $num_page_links_per_page, $pg_param)
{
global $pg_error, $pg_result, $max_pages, $page_id, $page_numbers_per_page, $pg_user_param;
$user_sql = $sql;
$page_numbers_per_page = $num_page_links_per_page;
$results_per_page = $num_results_per_page;
$pg_user_param = $pg_param;
$all_results = mysql_query($user_sql);
if($all_results)
{
if(empty($all_results))
{
$total_results = 0;
}
else
{
$total_results = mysql_num_rows($all_results);
}
$max_pages = ceil($total_results / $results_per_page);
if(isset($_GET['page_id']))
{
$page_id = (int) $_GET['page_id'];
if($page_id > $max_pages || empty($page_id))
{
$page_id = 1;
}
}
else
{
$page_id = 1;
}
$page_id_temp = ($page_id - 1) * $results_per_page;
$sql_offset = $page_id_temp;
$user_sql .= " limit $sql_offset, $results_per_page";
$pg_result = mysql_query($user_sql);
Create_Links();
}
else
{
$pg_error = 'Error with the sql query you entered: '.mysql_error();
}
}
function Create_Links()
{
global $pagination_output, $max_pages, $page_id, $page_numbers_per_page, $pg_user_param;
$pg_page_name = htmlspecialchars($_SERVER['PHP_SELF'] );
if($max_pages > 1)
{
if($page_id > 1)
{
$first_link = 'First ';
}
if($page_id < $max_pages)
{
$last_link = 'Last ';
}
$pre_id = $page_id - 1;
if($pre_id != 0)
{
$pre_link = 'Previous ';
}
$next_id = $page_id + 1;
if($next_id <= $max_pages)
{
$next_link = 'Next ';
}
if($page_id >= $page_numbers_per_page)
{
$start_point = ($page_id - $page_numbers_per_page) + 2;
}
else
{
$start_point = 1;
}
$loop_num = ($start_point + $page_numbers_per_page) - 1;
if($loop_num > $max_pages)
{
$loop_num = $max_pages;
}
$pagination_output = '<div class="pagination"> ';
$pagination_output .= $first_link;
$pagination_output .= $pre_link;
for($i = $start_point; $i <= $loop_num; $i++)
{
if($i == $page_id)
{
$pagination_output .= '<a class="current">'.$i.'</a> ';
}
else
{
$pagination_output .= ''.$i.' ';
}
}
$pagination_output .= $next_link;
$pagination_output .= $last_link;
$pagination_output .= '</div><br />';
}
}
?>
function pagination in your code is not returning the resulting mysql query resource, and your code is not receiving that from the pagination function call
you need
to add return $pg_result; in your pagination function
and add $result=pagination(....
Edit:
Sorry, I noticed you added pg_result to global, which does not need return and the solution I said, but you don't need mysql_query and fetch before that and I don't see where you print the results. there is only echo "", you can try the one I edited last, and see if it works for you.
Edit:
$today = date('D, d M, Y');
$sql = "SELECT * FROM table WHERE date = '$today'";
if ($_POST!="") {
$mydate = mysql_real_escape_string($_POST['datepicker']);
if ($mydate != "") {
$sql = "SELECT * FROM table WHERE date = '$mydate'";
}
}
$num_results_per_page = 8;
$num_page_links_per_page = 5;
$pg_param = "";
//$result=mysql_query($sql);
$pg_result=pagination($sql, $num_results_per_page, $num_page_links_per_page, $pg_param);
if($pg_error == '' && is_resource($pg_result))
{
if(mysql_num_rows($pg_result) > 0)
{
while($data = mysql_fetch_assoc($pg_result))
{
var_dump($data);
}
echo "</br>". $pagination_output;
}
else
{
echo "No Data.";
}
}
else
{
echo $pg_error;
}
pagination.php
$pg_error = '';
$pg_result = '';
$pagination_output = '';
$max_pages = '';
$page_id = '';
$page_numbers_per_page = '';
$pg_user_param = '';
function pagination($sql, $num_results_per_page, $num_page_links_per_page, $pg_param)
{
global $pg_error, $pg_result, $max_pages, $page_id, $page_numbers_per_page, $pg_user_param;
$user_sql = $sql;
$page_numbers_per_page = $num_page_links_per_page;
$results_per_page = $num_results_per_page;
$pg_user_param = $pg_param;
$all_results = mysql_query($user_sql);
if($all_results)
{
if(empty($all_results))
{
$total_results = 0;
}
else
{
$total_results = mysql_num_rows($all_results);
}
$max_pages = ceil($total_results / $results_per_page);
if(isset($_GET['page_id']))
{
$page_id = (int) $_GET['page_id'];
if($page_id > $max_pages || empty($page_id))
{
$page_id = 1;
}
}
else
{
$page_id = 1;
}
$page_id_temp = ($page_id - 1) * $results_per_page;
$sql_offset = $page_id_temp;
$user_sql .= " limit $sql_offset, $results_per_page";
$pg_result = mysql_query($user_sql);
Create_Links();
return $pg_result;
}
else
{
$pg_error = 'Error with the sql query you entered: '.mysql_error();
}
}
function Create_Links()
{
global $pagination_output, $max_pages, $page_id, $page_numbers_per_page, $pg_user_param;
$pg_page_name = htmlspecialchars($_SERVER['PHP_SELF'] );
if($max_pages > 1)
{
if($page_id > 1)
{
$first_link = 'First ';
}
if($page_id < $max_pages)
{
$last_link = 'Last ';
}
$pre_id = $page_id - 1;
if($pre_id != 0)
{
$pre_link = 'Previous ';
}
$next_id = $page_id + 1;
if($next_id <= $max_pages)
{
$next_link = 'Next ';
}
if($page_id >= $page_numbers_per_page)
{
$start_point = ($page_id - $page_numbers_per_page) + 2;
}
else
{
$start_point = 1;
}
$loop_num = ($start_point + $page_numbers_per_page) - 1;
if($loop_num > $max_pages)
{
$loop_num = $max_pages;
}
$pagination_output = '<div class="pagination"> ';
$pagination_output .= $first_link;
$pagination_output .= $pre_link;
for($i = $start_point; $i <= $loop_num; $i++)
{
if($i == $page_id)
{
$pagination_output .= '<a class="current">'.$i.'</a> ';
}
else
{
$pagination_output .= ''.$i.' ';
}
}
$pagination_output .= $next_link;
$pagination_output .= $last_link;
$pagination_output .= '</div><br />';
}
}
?>
Looks like you're mixing up the concept of $_POST and $_GET.
By having your pagination links point to '<a href="'.$pg_page_name.'?page_id='.$i . $pg_user_param.'"... You should be intercepting $_GET['page_id'] before you make your SQL query.
Your top code references $_POST['datepicker'] but you don't mention a form anywhere and your pagination links certainly aren't posting that data in your example.
You should use $pg_param = ""; to pass your own query parameters. Ex: &date=$date_value:
$pg_param = "&date=$date_value";