<?php
/********************************************************************************
* This script is brought to you by Vasplus Programming Blog by whom all copyrights are reserved.
* Website: www.vasplus.info
* Email: [email protected]
* Do not remove this copyright information from the top of this code.
*********************************************************************************/
include("config.php");
$Keyword = $_POST["txtKeyword"];
if(isset($_POST['page']) && !empty($_POST['page']))
{
$vpb_page_limit = 15; //This is the number of contents to display on each page
$vpb_check_contents = mysql_query("SELECT COUNT(*) as num FROM `ThaiIDCard` ORDER BY `id` ");
$vpb_get_total_pages = mysql_fetch_array($vpb_check_contents);
$vpb_get_total_pages = $vpb_get_total_pages[num];
$vpb_pagination_stages = 1;
$vpb_current_page = strip_tags($_POST['page']);
$vpb_start_page = ($vpb_current_page - 1) * $vpb_page_limit;
//This initializes the page setup
if($vpb_current_page == 0) { $vpb_current_page = 1; }
$vpb_previous_page = $vpb_current_page - 1;
$vpb_next_page = $vpb_current_page + 1;
$vpb_last_page = ceil($vpb_get_total_pages/$vpb_page_limit);
$vpb_lastpaged = $vpb_last_page - 1;
$vpb_pagination_system = '';
if($vpb_last_page > 1)
{
$vpb_pagination_system .= "<div class='vpb_pagination_system'>";
// Previous Page
if ($vpb_current_page > 1) { $vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_previous_page\");'><</a>"; }
else { $vpb_pagination_system.= "<span class='disabled'><</span>"; }
// Pages
if ($vpb_last_page < 3 + ($vpb_pagination_stages * 1)) // Not enough pages to breaking it up
{
for ($vpb_page_counter = 1; $vpb_page_counter <= $vpb_last_page; $vpb_page_counter++)
{
if ($vpb_page_counter == $vpb_current_page) {
$vpb_pagination_system.= "<span class='current'>$vpb_page_counter</span>";
}
else {
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_page_counter\");'>$vpb_page_counter</a>";
}
}
}
elseif($vpb_last_page > 3 + ($vpb_pagination_stages * 1)) // This hides few pages when the displayed pages are much
{
//Beginning only hide later pages
if($vpb_current_page < 1 + ($vpb_pagination_stages * 2))
{
for ($vpb_page_counter = 1; $vpb_page_counter < 3 + ($vpb_pagination_stages * 1); $vpb_page_counter++)
{
if ($vpb_page_counter == $vpb_current_page) {
$vpb_pagination_system.= "<span class='current'>$vpb_page_counter</span>";
}
else {
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_page_counter\");'>$vpb_page_counter</a>";
}
}
$vpb_pagination_system.= "...";
//$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_lastpaged\");'>$vpb_lastpaged</a>";
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_last_page\");'>$vpb_last_page</a>";
}
//Middle hide some front and some back
elseif($vpb_last_page - ($vpb_pagination_stages * 2) > $vpb_current_page && $vpb_current_page > ($vpb_pagination_stages * 1))
{
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"1\");'>1</a>";
//$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"2\");'>2</a>";
$vpb_pagination_system.= "...";
for ($vpb_page_counter = $vpb_current_page - $vpb_pagination_stages; $vpb_page_counter <= $vpb_current_page + $vpb_pagination_stages; $vpb_page_counter++)
{
if ($vpb_page_counter == $vpb_current_page) {
$vpb_pagination_system.= "<span class='current'>$vpb_page_counter</span>";
}
else {
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_page_counter\");'>$vpb_page_counter</a>";
}
}
$vpb_pagination_system.= "...";
//$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_lastpaged\");'>$vpb_lastpaged</a>";
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_last_page\");'>$vpb_last_page</a>";
}
//End only hide early pages
else
{
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"1\");'>1</a>";
//$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"2\");'>2</a>";
$vpb_pagination_system.= "...";
for ($vpb_page_counter = $vpb_last_page - (1 + ($vpb_pagination_stages * 1)); $vpb_page_counter <= $vpb_last_page; $vpb_page_counter++)
{
if ($vpb_page_counter == $vpb_current_page) {
$vpb_pagination_system.= "<span class='current'>$vpb_page_counter</span>";
}
else {
$vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_page_counter\");'>$vpb_page_counter</a>";
}
}
}
}
//Next Page
if ($vpb_current_page < $vpb_page_counter - 1) { $vpb_pagination_system.= "<a href='javascript:void(0);' onclick='vpb_pagination_system(\"$vpb_next_page\");'>></a>"; }
else { $vpb_pagination_system.= "<span class='disabled'>></span>"; }
$vpb_pagination_system.= "</div>";
}
//Check the contents for this page from the database
if(isset($_GET['keyword']) && $_GET['keyword']!=""){
$vpb_check_contents_second = mysql_query("SELECT * FROM ThaiIDCard from ThaiIDCard inner JOIN Gender ON ThaiIDCard.gender = Gender.gender WHERE dateread LIKE '%".$_GET['keyword']."%'
or timeread LIKE '%".$_GET['keyword']."%'
or id LIKE '%".$_GET['keyword']."%'
or objective LIKE '%".$_GET['keyword']."%'
or warning LIKE '%".$_GET['keyword']."%'
or issuenum LIKE '%".$_GET['keyword']."%'
or idnum LIKE '%".$_GET['keyword']."%'
or titleT LIKE '%".$_GET['keyword']."%'
or nameT LIKE '%".$_GET['keyword']."%'
or midnameT LIKE '%".$_GET['keyword']."%'
or surnameT LIKE '%".$Keyword."%'
or homenum LIKE '%".$_GET['keyword']."%'
or moo LIKE '%".$_GET['keyword']."%'
or trok LIKE '%".$_GET['keyword']."%'
or soi LIKE '%".$_GET['keyword']."%'
or thanon LIKE '%".$_GET['keyword']."%'
or tambon LIKE '%".$_GET['keyword']."%'
or amphur LIKE '%".$_GET['keyword']."%'
or province LIKE '%".$_GET['keyword']."%'
or gendername LIKE '%".$_GET['keyword']."%'
or birthdate LIKE '%".$_GET['keyword']."%'
or issueplace LIKE '%".$_GET['keyword']."%'
or issuedate LIKE '%".$_GET['keyword']."%'
or expirydate LIKE '%".$_GET['keyword']."%'
or app LIKE '%".$_GET['keyword']."%'
or reader LIKE '%".$_GET['keyword']."%' ORDER BY `id` LIMIT $vpb_start_page, $vpb_page_limit");
}
elseif($_GET['keyword']==""){
$vpb_check_contents_second = mysql_query("SELECT * FROM `ThaiIDCard` ORDER BY `id` LIMIT $vpb_start_page, $vpb_page_limit");
}
if(mysql_num_rows($vpb_check_contents_second) < 1)
{
echo "<div class='info'>Currently, there are no content in the database to display at the moment. Thanks...</div>";
}
else
{
?>
<div class="container">
<div class="row">
<?php
$i = 1;
//Get all contents for this page from the database and display on the screen to the user
while ($result = mysql_fetch_array($vpb_check_contents_second))
{
$birthdateT = strtotime($result['birthdate']);
$birthdateS = date("d-m-Y", $birthdateT);
?>
<div class="col-md-4">
<div class="cliente">
<p style="padding-bottom:7px;"></p>
<input id = "event_id" type="hidden" value="<?echo $result['id']?>">
<div class="media d-md-inline-flex " id= "media" >
<img id = "<?echo $result['id']?>" class="mr-3 rounded-circle align-self-center view_data" src="data:image/jpg;base64,<?php echo $result['photo'];?>"
alt="Generic placeholder image" width="80" hight="80" >
<div class="media-body view_data2" id = "<?echo $result['id']?>">
<p class="mb-0 ">
<h5>
<?php echo $result['titleT'] . " " . $result['nameT'];?>
</h5>
<?php echo $result['surnameT'];?>
<br>
<?php echo $result['idnum'];?>
<br>
<?php echo $birthdateS;?>
<br>
<?php echo $result['province'];?>
<br>
<p style="padding-bottom:7px;"></p>
</div>
<input name="chk[]" type="checkbox" value="<?php echo $result['id'];?>">
</div>
</div>
</div>
<?php $i++; } ?>
</div>
</div>
<br clear="all" />
<?php
?>
<br clear="all" />
<div style="" align="left"><?php echo $vpb_pagination_system; ?></div><!-- This is the pagination buttons -->
<br clear="all" />
<?php
}
}
?>
$vpb_check_contents = mysql_query("SELECT COUNT(*) as num FROM `ThaiIDCard` ORDER BY `id` ");
เวลาคุณ count จำนวน ต้อง กำหนด condition เหมือนกันกับ statement ที่นำมาแสดงผล
$vpb_check_contents = mysql_query("SELECT COUNT(*) as num FROM `ThaiIDCard` where (Condition) ORDER BY `id` ");