How to make PHP Pagination is working in Mobile? - php

I have implement pagination in PHP.
It's works fine on Desktop and Laptop but but its not working on mobile devices.
member_list.php
<?php
include "../connection.php";
extract($_REQUEST);
$perPage = 50; // total records per page
// page
$conditionArr = array(); // array for condition
$condition = ""; // conditions
$pages = ""; // how many pages created
$type = "";
$company = "";
$message = "";
$rersArr = array();
$data = array();
$templeArr = array();
if ($sabhasadnumber != "") {
array_push($conditionArr, "sabhasad_number = '" . $sabhasadnumber . "'");
}
if ($Sakhe != "") {
array_push($conditionArr, "sakhe_id = '" . $Sakhe . "'");
}
if ($g != "") {
array_push($conditionArr, "gender LIKE '%" . $g . "%'");
}
$sql = "SELECT * FROM members WHERE village_id = '$id' and is_active = '1' and status = '1' ";
if (sizeOf($conditionArr) > 0) {
$condition = implode(" AND ", $conditionArr);
// echo $condition;
$sql .= " AND $condition";
}
$start = ($page - 1) * $perPage;
$sql1 = mysqli_query($conn, $sql) or die(mysqli_error($conn));
$count = mysqli_num_rows($sql1);
$pages = ceil($count / $perPage);
$sql .= " ORDER BY members_id ASC";
$sql .= " limit $start,$perPage ";
$num_of_rows = mysqli_num_rows($sql1);
?>
<input type="hidden" name="total_page" id="total_page" value="<?php echo $pages; ?>">
<input type="hidden" name="current_page" class="current_page" id="current_page"
value="<?php echo $page; ?>">
<div class="member--items">
<div class="row gutter--15 AdjustRow">
<div class="row">
<?php
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
?>
<div class="col-md-3 col-xs-6 col-xxs-12" style="height:300px">
<div class="member--item ">
<?php
$imgurl = "";
if ($row["image"] != "") {
$imgurl = "../admin/uploads/" . $row["image"];
} else {
$imgurl = "../admin/uploads/default_profile.jpg";
}
?>
<div class="img img-circle">
<a href="sabhasad_family.php?id=<?php echo $row['sabhasad_number']; ?>" class="btn-link">
<img src="<?php echo $imgurl; ?>" alt=""
style="height: 150px; width: 150px;">
<!-- <img src="../admin/uploads/default_profile.jpg" alt=""-->
<!-- style="height: 150px; width: 150px;">-->
</a>
</div>
<div class="name">
<h3 class="h fs--12">
<p>
<a href="sabhasad_family.php?id=<?php echo $row['sabhasad_number']; ?>"> <?php echo $row['surname'] ." " ;
echo $row['name'] ." ";
echo $row['middle_name'] ." "; ?></a></p>
</h3>
</div>
<div class="activity">
<p>સભાસદ નંબર : <?php echo $row['sabhasad_number']; ?> </p>
</div>
</div>
</div>
<?php
}
}
else { ?>
<?php
}
?>
member_list.js
var page = 1;
var total_page = "";
function getresult(searches) {
$.ajax({
url: "process/member_list.php",
type: "post",
data: {
sabhasadnumber: $("#sabhasadnumber").val(),
id: $("#village_id").val(),
Sakhe: $("#Sakhe").val(),
g: $("#g").val(),
page: page
},
success: function (data) {
// alert(data);
if (data != "") {
if (searches === true) {
$("#mlist").html(data);
} else {
$("#mlist").append(data);
}
}
}
});
}
$(document).ready(function () {
getresult(false);
$(window).scroll(function () {
if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
if (parseInt($(".current_page:last").val()) < parseInt($("#total_page").val())) {
page = parseInt($(".current_page:last").val()) + 1;
// alert("scrool"+$(".current_page:last").val());
getresult(false);
}
}
});
$("#reset").click(function () {
$("#Sakhe").val("");
$("#sabhasadnumber").val("");
$("#g").val("");
page = 1;
getresult(true);
});
$("#shopsubmit").click(function () {
page = 1;
getresult(true);
});
$("#freset").click(function () {
$("#subcategory").val("");
page = 1;
getresult(true);
});
});
My front page code look like this
village.php
<?php
include 'connection.php';
include 'header.php';
$id = $_GET['id'];
$totalvillagemember = mysqli_num_rows(mysqli_query($conn, "select members_id from members WHERE village_id = $id AND is_active = '1' and status = '1' "));
$villagename = mysqli_query($conn, "SELECT name from village WHERE village_id = $id");
$row1 = mysqli_fetch_array($villagename);
?>
<body>
<!-- Preloader Start -->
<div id="preloader">
<div class="preloader--inner"></div>
</div>
<!-- Preloader End -->
<!-- Wrapper Start -->
<div class="wrapper">
<!-- Header Section Start -->
<!-- Header Section End -->
<!-- Page Header Start -->
<div class="page--header pt--60 pb--60 text-center" data-bg-img="img/page-header-img/bg.jpg" data-overlay="0.85">
<div class="container">
<div class="title">
<h2 class="h1 text-white">સભ્યો</h2>
</div>
<ul class="breadcrumb text-gray ff--primary">
<li>હોમ</li>
<li class="active"><span class="text-primary">સભ્યો</span></li>
</ul>
</div>
</div>
<!-- Page Header End -->
<!-- Page Wrapper Start -->
<section class="page--wrapper pt--80 pb--20">
<div class="container">
<div class="row">
<!-- Main Content Start -->
<div class="main--content col-md-8 pb--60" data-trigger="stickyScroll">
<div class="main--content-inner">
<!-- Filter Nav Start -->
<div class="filter--nav clearfix">
<div class="filter--link">
<h2 class="">ગામ : <?php echo $row1['name']; ?></h2>
<h2 class="">કુલ સભ્ય :<?php echo number_format($totalvillagemember) ?></h2>
</div>
</div>
<div id="mlist" name="mlist">
</div>
<!-- Page Count End -->
</div>
</div>
<!-- Main Content End -->
<!-- Main Sidebar Start -->
<div class="main--sidebar col-md-4 pb--60" data-trigger="stickyScroll">
<!-- Widget Start -->
<div class="widget">
<h2 class="h4 fw--700 widget--title">સભ્ય શોધો</h2>
<!-- Buddy Finder Widget Start -->
<div class="buddy-finder--widget">
<form name="village" id="village">
<div class="row">
<div class="col-xs-6 col-xxs-12">
<div class="form-group">
<label>
<span class="text-darker ff--primary fw--500">શોધી રહ્યો છુ</span>
<select class="form-control form-sm" name="g" id="g">
<option value=""> પસંદ કરો
</option>
<option value = "M">પુરુષ</option>
<option value = "F">સ્ત્રી</option>
</select>
</label>
</div>
</div>
<div class="col-xs-6 col-xxs-12">
<div class="form-group">
<label>
<span class="text-darker ff--primary fw--500">સભાસદ નંબર</span>
<input type="text" name="sabhasadnumber" id="sabhasadnumber"
class="form-control form-sm"
placeholder="સભાસદ નંબર">
</label>
</div>
</div>
<div class="col-xs-6 col-xxs-12">
<div class="form-group">
<label>
<input type="hidden" id="village_id" name="village_id"
value="<?php echo $id; ?>">
<span class="text-darker ff--primary fw--500">સાખે</span>
<select class="form-control form-sm" name="Sakhe" id="Sakhe">
<option value=""> સાખે પસંદ કરો
</option>
<?php
$query = mysqli_query($conn, "select * from sakhe where status = 1 order by sakhe_id asc");
while ($row = mysqli_fetch_array($query)) {
echo "<option value = " . $row['sakhe_id'] . ">" . $row['name'] . "</option>";
}
?>
</select>
</label>
</div>
</div>
<div class="col-xs-12">
<button type="button" onclick="getresult()" class="btn btn-primary" id="shopsubmit" name="shopsubmit">
સબમિટ કરો
</button>
<button type="button" onclick="getresult()" class="btn btn-primary"
id="reset" name="reset">
ફરીથી સેટ કરો
</button>
</div>
</div>
</form>
</div>
</div>
<!-- Widget End -->
</div>
<!-- Main Sidebar End -->
</div>
</div>
</section>
<!-- Page Wrapper End -->
<!-- Footer Section Start -->
<!-- Footer Widgets End -->
<!-- Footer Extra Start -->
<?php include 'footer.php'; ?>
<!-- Footer Section End -->
</div>
<!-- Wrapper End -->
<!-- Back To Top Button Start -->
<div id="backToTop">
<i class="fa fa-caret-up"></i>
</div>
<!-- Back To Top Button End -->
<!-- ==== Plugins Bundle ==== -->
<script src="js/plugins.min.js"></script>
<!-- ==== Color Switcher Plugin ==== -->
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<!-- ==== Main Script ==== -->
<script src="js/main.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<!--<script src="http://malsup.github.com/jquery.form.js"></script>-->
<script src="myjs/member_list.js"></script>
</body>
<!-- Mirrored from themelooks.us/demo/socifly/html/members.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 30 Sep 2019 09:33:46 GMT -->
</html>
This pagination is not working only on Mobile devices.
Please help.

Related

How to find the difference between event dates in the time line using php?

Actually I am working on the 2002 ( old php project) based on the requirement. So my work is to show the difference between events markers based on the dates by placing some width dynamically in php. So I wrote the code after that it is not even displaying the events markers in the page.
I will provide the code which I wrote for this requirement.
function getEvents($uid)
{
$timeLineQry = mysql_query("select * from timelines where user_id = $uid and status=1 order by id desc");
if(mysql_num_rows($timeLineQry) > 0)
{
$data='';
while($tres = mysql_fetch_assoc($timeLineQry))
{
$data.='<div class="events-chat" id="timeline'.$tres['id'].'">
<button class="btn btn-success" onclick="addEvent('.$tres['id'].')"> Add Event</button>
<div id="" style="float:right;">
<span style="margin-left: 10px;color: #696767;
cursor: pointer;margin-right: 25px;font-size: 16px;font-weight: bolder;font-family: inherit;" onclick="getTimeLine(\''.$tres['title'].'\',\''.$tres['description'].'\',\''.$tres['id'].'\')">'.$tres['title'].'</span>
<i class="glyphicon glyphicon-trash" onclick="deleteTimeline('.$tres['id'].')"></i>
</div>
<div style="clear:both;margin-bottom:35px;"></div>
<div id="eventBlck'.$tres['id'].'">';
//echo "select * from events where user_id = $uid and timeline=".$tres['id'];exit;
$user_exe1 = mysql_query("select * from events where user_id = $uid and timeline=".$tres['id']." order by date asc");
if(mysql_num_rows($user_exe1) > 0) {
$i=1;
$data.='<div class="events-chat-inner">
<div class="all-cht-blk">
<div class="event-border">
<div class="c-dot" style="float:left;position:absolute;left:-4px;top:-4px;"></div>
<div class="c-dot" style="float:right;position:absolute;right:-4px;top:-4px;"></div>
</div>
';
while($res = mysql_fetch_assoc($user_exe1))
{
//Here is the code I just tried to subtract the date of one event from date of another event.
$datecount = count($res['date']);
for($j = 0; $j <= $datecount; $j++){
$previous_event_date = strtotime($res['date'][j]);
$present_event_date = strtotime($res['date'][j+1]);
$distance = $previous_event_date - $present_event_date;
$distance = floor($distance/(60 * 60 * 24));
$case1 = range(0,20);
$case2 = range(1,40);
if(in_array($distance,$case1))
{
$distancestyle = 'width:130px';
}
elseif(in_array($distance,$case2))
{
$distancestyle = 'width:180px';
}
else
{
$distancestyle = 'width:230px';
}
if($i%2==0){$bc='#f45e34';}else if($i%3==0){$bc='#fa454a';}else if($i%4==0){$bc='#3cb54b';}else if($i%5==0){$bc='#03aeac';}else{$bc='#9f388b';}
if($i%2==0)
{
$data.='<div class="event-ct-blk" style='\$distancestyle\'>
<h3 onclick="getData('.$res['id'].',
\''.str_replace("'","\'",$res['name']).'\',
\''.str_replace("'","\'",$res['description']).'\',
\''.date('m-d-Y',strtotime($res['date'])).'\');">'.$res['name'].'</h3>
<p onclick="getData('.$res['id'].',\''.str_replace("'","\'",$res['name']).'\',\''.str_replace("'","\'",$res['description']).'\',\''.date('m-d-Y',strtotime($res['date'])).'\');">'.$res['description'].' </p>
<div class="pointer">
<div class="c-dot"></div>
<div class="p-strip-2" style="height:125px;"></div>
<div class="q-circle-outer" onclick="getData('.$res['id'].',\''.str_replace("'","\'",$res['name']).'\',\''.str_replace("'","\'",$res['description']).'\',\''.date('m-d-Y',strtotime($res['date'])).'\');">
<div class="q-circle" style="background: '.$bc.';"></div>
</div>
<div class="p-strip" style="height:25px;"></div>
<div class="c-dot"></div>
</div>
<p class="q-date" onclick="getData('.$res['id'].',
\''.str_replace("'","\'",$res['name']).'\',
\''.str_replace("'","\'",$res['description']).'\',
\''.date('m-d-Y',strtotime($res['date'])).'\');"> Date: '.date('M-d-Y',strtotime($res['date'])).' </p>
</div>';
}
else
{
$data.='<div class="event-ct-blk" style='\$distancestyle\'>
<h3 onclick="getData('.$res['id'].',\''.str_replace("'","\'",$res['name']).'\',\''.str_replace("'","\'",$res['description']).'\',\''.date('m-d-Y',strtotime($res['date'])).'\');">'.$res['name'].'</h3>
<p onclick="getData('.$res['id'].',\''.str_replace("'","\'",$res['name']).'\',\''.str_replace("'","\'",$res['description']).'\',\''.date('m-d-Y',strtotime($res['date'])).'\');">'.$res['description'].' </p>
<div class="pointer">
<div class="c-dot"></div>
<div class="p-strip" style="height:25px;"></div>
<div class="q-circle-outer" onclick="getData('.$res['id'].',\''.str_replace("'","\'",$res['name']).'\',\''.str_replace("'","\'",$res['description']).'\',\''.date('m-d-Y',strtotime($res['date'])).'\');">
<div class="q-circle" style="background: '.$bc.';"></div>
</div>
<div class="p-strip-2" style="height:125px;"></div>
<div class="c-dot"></div>
</div>
<p class="q-date" onclick="getData('.$res['id'].',\''.str_replace("'","\'",$res['name']).'\',\''.str_replace("'","\'",$res['description']).'\',\''.date('m-d-Y',strtotime($res['date'])).'\');"> Date: '.date('M-d-Y',strtotime($res['date'])).' </p>
</div>';
}
$i++;
}
$data.='</div></div>';
}
else
{
$data.='<div class="event-border" style="width:96%;">
<div class="c-dot" style="float:left;position:absolute;left:-4px;top:-4px;"></div>
<div class="c-dot" style="float:right;position:absolute;right:-4px;top:-4px;"></div>
</div><div style="text-align:center;margin-top:78px;font-size: 18px;"><p>No events added.</p></div>';
}
$data.='</div></div>';
}
}
else
{
$data='<div class="events-chat" id="timeline1"> <button class="btn btn-success" onclick="addEvent(1)"> Add Event</button><div style="clear:both;margin-bottom:35px;"></div><div id="eventBlck1"> <div class="event-border" style="width:96%;">
<div class="c-dot" style="float:left;position:absolute;left:-4px;top:-4px;"></div>
<div class="c-dot" style="float:right;position:absolute;right:-4px;top:-4px;"></div>
</div><div style="text-align:center;margin-top:78px;font-size: 18px;"><p>No events added.</p></div></div></div>';
}
}//end for loop
return $data;
}
In this code I place the code which I marked as the comments and actually this is the code I have present but after working on this file events are not showing canyou please see the issue in this code or any errors.

Two Pictures in one row in a large gallery

I have a Problem:
I coded a whole gallery with bootstrap and in this gallery are gaps. There are 100 pictures on 7 pages and instead of going down in one picture block it has gaps between it. This follows no obvious order.
Here is a picture:
So I wanted to take the whole col-md etc and picture container away and make my own columns. So that it works properly, but my solution from the internet doesn't work... I think it must be a problem with PHP that it is in a For loop and not in pure HTML like in the solutions. But I don't know how to solve it.
Here is the PHP code before:
<?php
//require_once("galerie-config.php");
if (!isset($_GET['pageindex'])) {
$_GET['pageindex'] = "1";
}....
<script type='text/javascript' src='../js/Bateaux/jquery/jquery.js'></script>
<script type='text/javascript' src='../js/Bateaux/jquery/jquery-migrate.min.js'></script>
<script type='text/javascript' src='../revslider/public/assets/js/jquery.themepunch.tools.min.js'></script>
<script type='text/javascript' src='../revslider/public/assets/js/jquery.themepunch.revolution.min.js'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var BateauxOptions = {"ajax_url":"../js/admin-ajax.html"};
/* ]]> */
</script>
<script type='text/javascript'>
/* <![CDATA[ */
var mejsL10n = {
"language": "en-US",
"strings": {
"Close": "Close",
"Fullscreen": "Fullscreen",
"Download File": "Download File",
"Download Video": "Download Video",
"Play\/Pause": "Play\/Pause",
"Mute Toggle": "Mute Toggle",
"None": "None",
"Turn off Fullscreen": "Turn off Fullscreen",
"Go Fullscreen": "Go Fullscreen",
"Unmute": "Unmute",
"Mute": "Mute",
"Captions\/Subtitles": "Captions\/Subtitles"
}
};
var _wpmejsSettings = {
"pluginPath": "../js\/mediaelement\/"
};
/* ]]> */
</script>
<script type='text/javascript' src='../js/Bateaux/hoverIntent.min.js'></script>
<script type='text/javascript' src='../js/Bateaux/jquery/ui/widget.min.js'></script>
<script type='text/javascript' src='../js/Bateaux/main-vendors.min.js'></script>
<script type='text/javascript' src='../js/Bateaux/main.min.js'></script>
<!-- INNER BANNER STARTS
========================================================================= -->
<div class="inner-banner" style="background-color:#fff;">
<div class="container">
<ol class="breadcrumb">
<li>Home</li>
<li>Referenzen</li>
<li class="active">Galerie</li>
</ol>
<h1>Galerie</h1>
</div>
</div>
<!-- /. INNER BANNER STARTS
========================================================================= -->
<!-- PORTFOLIO STARTS
========================================================================= -->
**<div class="container contents portfolio">
<div class="row no-gutter-6">
<?php
require_once("dbh.php");
$numPicturesPerPage = 20;
//$seiten = [0,1,2,3,4,5,6,7,8,9,10];
global $pageIndex;
$pageIndex = 1;
if (isset($_GET['pageindex'])) {
$pageIndex = $_GET['pageindex'];
}
$bildauswahl = $numPicturesPerPage * ($pageIndex -1);
$sql = "SELECT * FROM galeriebilder LIMIT $bildauswahl,$numPicturesPerPage";
$rows = $dbh->query($sql);
$imgPathNames = [];
$i = 0;
foreach ($rows as $row) {
//for ($i=0;$i<$numPicturesPerPage;$i++) {
$bildcode = $row['bildcode'];
//array_push($imgPathNames, $bildcode);
$i++;
echo "<!-- Picture Starts -->";
***echo "<div class='col-lg-6 col-md-6 col-sm-6'>";
echo "<div class='picture'>";
echo "<img id='aquarium-galerie-" . $i . "' src='../images/galerie/". "$bildcode" . "'" . " onclick='alert(\"" . $bildcode . "\")' class='img-responsive editable' alt='' />";
echo "</div>";
echo "</div>";
//}***
?>
<!-- Picture Ends -->
<?php
}
?>
</div>
<div class="row">
<!-- Picture Starts -->
<?php
global $numPages;
$sql ="SELECT count(bild_id) FROM galeriebilder";
$rows = $dbh->query($sql);
foreach ($rows as $row){
global $numPictures;
$numPictures = $row[0];
}
$biggerThan = $numPictures % $numPicturesPerPage;
$numPages = intval(floor($numPictures / $numPicturesPerPage));
if ($biggerThan > 0) {
$numPages++;
}
if (preg_match("/d+/", $pageIndex, $matches)) { $pageIndex = $matches[0]; } // Filtert die Zahl aus z.B. 2.php heraus
function navSeiten($aktuell,$gesamt) {
$pageIndex = $_GET['pageindex'];
$next = $aktuell + 1;
$previous = $aktuell - 1;
$ausgabe = '<ul class="pager">';
if ($aktuell <= 3 ) {
$seiten = array(1,2,3,4,5);
}else if ($aktuell == $gesamt -3 ) {
$seiten = array($aktuell -2 ,$aktuell-1 ,$aktuell , $aktuell +1 , $aktuell +2);
}else if ($aktuell >= $gesamt -3 ) {
$seiten = array($gesamt -4 , $gesamt -3, $gesamt -2 , $gesamt -1, $gesamt );
} else {
$seiten = array( $aktuell -2 ,$aktuell-1 ,$aktuell , $aktuell +1 , $aktuell +2);
}
//echo ($pageIndex);
?>
<li class="previous" style="<?php
if ($pageIndex == "1" ) { echo "display:none ";} ?>" >
<a href="galerie.php?pageindex=' . $previous . '" aria-label="Previous">
<span aria-hidden="true"></span>
</a>
</li>
<?php
foreach ($seiten as $seite) {
if ($seite == $pageIndex) {
$ausgabe .= '<li class="active">' . $seite . '</li>';
} else {
$ausgabe .='<li>' . $seite . '</li>';
}
}
?><li class="next" style="
<?php
/*$sql ="SELECT count(bild_id) FROM galeriebilder";
$rows = $dbh->query($sql);
foreach ($rows as $row) {
$numPictures = $row[0];
}*/
$numPicturesPerPage = 20;
$numPages = intval(floor($numPictures / $numPicturesPerPage));
if ($pageIndex == $numPages ) { echo "display:none"; }
?>" >
<a href="galerie.php?pageindex=' . $next . '" aria-label="Next">
<span aria-hidden="true"></span>
</a>
</li>
<?php
//echo $numPages;
echo $numPictures;
$ausgabe .= '</ul>';
return $ausgabe;
}
?>
<div class="col-lg-12 no-gutter-12 pagging">
<?php echo navSeiten($pageIndex,$numPages) ?> <!-- Dies ist der Funktionsaufruf der Funktion die die komplette Leiste der Seitenaufrufe-->
</div>
</div>
</div>
<!-- /. PORTFOLIO ENDS**
========================================================================= -->
<!-- FOOTER STARTS
========================================================================= -->
<footer class="parallax-1">
<!-- Social Media Starts -->
<div class="social-media transparent-black-bg" style="background-color:#000;">
<div class="container">
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
<div class="caption">Facebook</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
<div class="caption">Youtube</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
<div class="caption">Instagram</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
<div class="caption">Google+</div>
</div>
</div>
</div>
</div>
<!-- Social Media Ends -->
<!-- Contact Info Starts -->
<div class="contact-info" style="background-color:#313131;">
<div class="container">
<div class="row">
<!-- Address Starts -->
<div class="col-lg-3 col-md-3 col-sm-3 address">
<div class="footer-logo"><img src="../images/Startseite/Logo-Footer.png" class="img-responsive" alt="Logo von Biological Aqua Dreams (eine Koralle)" style="margin-left:0;"></div>
<address>
<strong>KONRAD-HAUSSMANN-WEG 6<br>
D-73614 SCHORNDORF</strong>
<div class="phone">+49 176 6316 1653</div>
<div>INFO#BIOLOGICAL-AQUA-DREAMS.COM</div>
</address>
<div class="about">Sie haben Fragen? Kontaktieren Sie uns einfach telefonisch oder per Email.</div>
</div>
<!-- Address Ends -->
<!-- Blog Posts Starts -->
<div class="col-lg-4 col-md-4 col-sm-4 latest-posts">
<h1>ALLES AUF EINEN BLICK</h1>
<div class="post">
<h2>Unsere Leistungen </h2>
<div class="info"><span class="user">Erfahren Sie mehr über uns</span></div>
</div>
<div class="post">
<h2>Wartung und Reparatur</h2>
<div class="info"><span class="user">Wir sind für Sie da</span></div>
</div>
</div>
<!-- Blog Posts Ends -->
<!-- Get in Touch Starts -->
<div class="col-lg-5 col-md-5 col-sm-5 get-in-touch">
<h1>KONTAKT AUFNEHMEN</h1>
<form action='../process.php' method='post' name='ContactForm' id='ContactForm'>
<div class="form-group">
<input type="email" class="form-control" name="email" placeholder="Email *">
</div>
<textarea rows="5" class="form-control" name="comment" placeholder="Nachricht *"></textarea>
<div id='message_post'></div>
<input class="btn btn-default" type='submit' value='SENDEN' name='submitf' id="submitf" style="outline:none;">
</form>
</div>
<!-- Get in Touch Ends -->
</div>
</div>
</div>
<!-- Contact Info Ends -->
<!-- Copyright Starts -->
<div class="copyright light-grey-bg">
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">© 2018 BIOLOGICAL AQUA DREAMS |
DATENSCHUTZ | IMPRESSUM</div>
<div class="col-lg-4 col-md-4 col-sm-4 created-by">Created by Crew Ad</div>
</div>
</div>
</div>
<!-- Copyright Starts -->
</footer>
....
And here after my solution:
<div class="container contents portfolio">
<div class="row no-gutter-6">
<?php
require_once("dbh.php");
$numPicturesPerPage = 20;
//$seiten = [0,1,2,3,4,5,6,7,8,9,10];
global $pageIndex;
$pageIndex = 1;
if (isset($_GET['pageindex'])) {
$pageIndex = $_GET['pageindex'];
}
$bildauswahl = $numPicturesPerPage * ($pageIndex -1);
$sql = "SELECT * FROM galeriebilder LIMIT $bildauswahl,$numPicturesPerPage";
$rows = $dbh->query($sql);
$imgPathNames = [];
$i = 0;
foreach ($rows as $row) {
//for ($i=0;$i<$numPicturesPerPage;$i++) {
$bildcode = $row['bildcode'];
//array_push($imgPathNames, $bildcode);
$i++;
echo "<!-- Picture Starts -->";
//echo "<div class='col-lg-6 col-md-6 col-sm-6'>";
echo "<div class='picture'>";
echo "<figure><img id='aquarium-galerie-" . $i . "' src='../images/galerie/". "$bildcode" .
"'" . "width='750px' height='500px' onclick='alert(\"" . $bildcode .
"\")' class='img-responsive pic editable' alt='' /></figure>";
echo "</div>";
//echo "</div>";
//}
?>
<!-- Picture Ends -->
<?php
}
?>
</div>
<div class="row">
<!-- Picture Starts -->
<?php
global $numPages;
$sql ="SELECT count(bild_id) FROM galeriebilder";
$rows = $dbh->query($sql);
foreach ($rows as $row){
global $numPictures;
$numPictures = $row[0];
}
$biggerThan = $numPictures % $numPicturesPerPage;
$numPages = intval(floor($numPictures / $numPicturesPerPage));
if ($biggerThan > 0) {
$numPages++;
}
if (preg_match("/d+/", $pageIndex, $matches)) { $pageIndex = $matches[0]; } // Filtert die Zahl aus z.B. 2.php heraus
function navSeiten($aktuell,$gesamt) {
$pageIndex = $_GET['pageindex'];
$next = $aktuell + 1;
$previous = $aktuell - 1;
$ausgabe = '<ul class="pager">';
if ($aktuell <= 3 ) {
$seiten = array(1,2,3,4,5);
}else if ($aktuell == $gesamt -3 ) {
$seiten = array($aktuell -2 ,$aktuell-1 ,$aktuell , $aktuell +1 , $aktuell +2);
}else if ($aktuell >= $gesamt -3 ) {
$seiten = array($gesamt -4 , $gesamt -3, $gesamt -2 , $gesamt -1, $gesamt );
} else {
$seiten = array( $aktuell -2 ,$aktuell-1 ,$aktuell , $aktuell +1 , $aktuell +2);
}
//echo ($pageIndex);
?>
<li class="previous" style="<?php
if ($pageIndex == "1" ) { echo "display:none ";} ?>" >
<a href="galerie.php?pageindex=' . $previous . '" aria-label="Previous">
<span aria-hidden="true"></span>
</a>
</li>
<?php
foreach ($seiten as $seite) {
if ($seite == $pageIndex) {
$ausgabe .= '<li class="active">' . $seite . '</li>';
} else {
$ausgabe .='<li>' . $seite . '</li>';
}
}
?><li class="next" style="
<?php
/*$sql ="SELECT count(bild_id) FROM galeriebilder";
$rows = $dbh->query($sql);
foreach ($rows as $row) {
$numPictures = $row[0];
}*/
$numPicturesPerPage = 20;
$numPages = intval(floor($numPictures / $numPicturesPerPage));
if ($pageIndex == $numPages ) { echo "display:none"; }
?>" >
<a href="galerie.php?pageindex=' . $next . '" aria-label="Next">
<span aria-hidden="true"></span>
</a>
</li>
<?php
//echo $numPages;
echo $numPictures;
$ausgabe .= '</ul>';
return $ausgabe;
}
?>
<div class="col-lg-12 no-gutter-12 pagging">
<?php echo navSeiten($pageIndex,$numPages) ?> <!-- Dies ist der Funktionsaufruf der Funktion die die komplette Leiste der Seitenaufrufe-->
</div>
</div>
</div>
Here is the CSS Code:
.picture {
clear:both;
}
.pic {
//float: left;
width:50%;
display:block;
}
figure {
display: table-cell;
text-align: center;
}
Sorry that it's now a mix of all solutions I found on the internet. I didn't changed it already.
I hope you can help me.
With kindly greetings Lukas Stetter

php pagination has some error

I'm trying to materialize pagination. I want to fetch like
$sql2 = "select * from phptest.memo order by num desc limit $start,$start+$scale";
and i used while paragraph to show memo and ripple (ripple database has parent field that what number of memo and it's order num primary field) but I think it seems like typed wrong code what should i do? It's image that I want make
Expected result:
Error:
<?php
session_start();
// echo "<a href='memo.php?page=$i'> $i </a>";
$scale=5; // page per writing
// start recored number newest writing is up
// $page 값에 다른 시작 레코드 넘버값, 가장 높은 글번호(최신글 부터 밑으로)
$start = ($page - 1) * $scale; //0,5,10 ...
if(!isset($_REQUEST["page"]))
{
$page = 1; // initialize seeing page
}else{
$page = $_REQUEST["page"];
}
require_once '../lib/dbconn.php';
$pdo = db_connect();
if(isset($_SESSION["userid"])){
$userid = $_SESSION["userid"];
}else{
$userid = "";
}
// start recored number newest writing is up
try{
//$sql = "select * from phptest.memo order by num desc";
$sql2 = "select * from phptest.memo order by num desc limit $start,$start+$scale";
$stmh = $pdo->query($sql2);
} catch (PDOException $ex) {`enter code here`
print "오류: ".$ex->getMessage();
}
$total_record = $stmh->rowCount();
$number = $total_record - $start;
// 전체 페이지 수 계산..
if ($total_record % $scale == 0)
$total_page = floor($total_record/$scale);
else
$total_page = floor($total_record/$scale) + 1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<link href="../css/common.css" rel="stylesheet" type="text/css" media="all">
<link href="../css/memo.css" rel="stylesheet" type="text/css" media="all">
</head>
<body>
<div id="wrap">
<div id="header">
<?php include "../lib/top_login2.php"; ?>
</div> <!-- end of header -->
<div id="menu">
<?php include "../lib/top_menu2.php"; ?>
</div> <!-- end of menu -->
<div id="content">
<div id="col1">
<div id="left_menu">
<?php
include "../lib/left_menu.php";
?>
</div>
</div>
<div id="col2">
<div id="title">
<img src="../img/title_memo.gif">
</div>
<?php
// if(isset($_SESSION["userid"])){
?>
<div id="memo_row1">
<form name="memo_form" method="post" action="insert.php">
<?php if(isset($_SESSION['nick'])){ ?>
<div id="memo_writer"><span >▷ <?=$_SESSION['nick'] ?> </span></div>
<?php }?>
<div id="memo1"><textarea rows="6" cols="95" name="content"></textarea></div>
<div id="memo2"><input type="image" src="../img/memo_button.gif"></div>
</form>
</div> <!-- end of memo_row1 -->
<?php // }
while ($row = $stmh->fetch(PDO::FETCH_ASSOC))
{
// $stmh = $pdo->query($sql2);
//$row[$i] = $row;
// $row = $stmh2->fetch(PDO::FETCH_ASSOC);
$memo_id = $row['id'];
$memo_num = $row['num'];
$memo_date = $row['regist_day'];
$memo_nick = $row['nick'];
$memo_content = $row['content'];
$memo_content = str_replace("\n", "<br>", $row['content']);
$memo_content = str_replace(" ", " ", $memo_content);
?>
<div id="memo_writer_title">
<ul>
<li id="writer_title1"><?= $memo_num ?></li> <!--article number -->
<li id="writer_title2"><?= $memo_nick ?></li>
<li id="writer_title3"><?= $memo_date ?></li>
<li id="writer_title4">
<?php
if($userid=="admin" || $userid==$memo_id)
echo "<a href='delete.php?num=$memo_num'>[삭제]</a>";
?>
</li>
</ul>
</div>
<div id="memo_content"><?= $memo_content ?>
</div>
<div id="ripple">
<div id="ripple1">덧글</div>
<div id="ripple2">
<?php
$sql3 = "select * from phptest.memo_ripple where parent=$memo_num";
$stmh3 = $pdo->query($sql3);
while ($row_ripple = $stmh3->fetch(PDO::FETCH_ASSOC))
{
$ripple_num = $row_ripple["num"];
$ripple_id = $row_ripple["id"];
$ripple_nick = $row_ripple["nick"];
$ripple_content = str_replace("\n", "<br>", $row_ripple["content"]);
$ripple_content = str_replace(" ", " ", $ripple_content);
$ripple_date = $row_ripple["regist_day"];
?>
<div id="ripple_title">
<ul>
<li><?= $ripple_nick ?> <?= $ripple_date ?></li>
<li id="mdi_del">
<?php
if($userid=="admin" || $userid==$ripple_id)
echo "<a href='delete_ripple.php?num=$ripple_num'>삭제</a>";
?>
</li>
</ul>
</div>
<div id="ripple_content"> <?= $ripple_content ?></div>
<?php
}
if(isset($_SESSION["userid"])){
?>
<form name="ripple_form" method="post" action="insert_ripple.php">
<input type="hidden" name="num" value="<?= $memo_num ?>">
<div id="ripple_insert">
<div id="ripple_textarea">
<textarea rows="3" cols="80" name="ripple_content"></textarea>
</div>
<div id="ripple_button"><input type="image" src="../img/memo_ripple_button.png"></div>
</div>
</form>
<?php } ?>
</div> <!-- end of ripple2 -->
<div class="clear"></div>
<div class="linespace_10"></div>
<?php
//$number--;
}
?>
<div id="page_num"> ◀ 이전
<?php
// page link num
// 게시판 목록 하단에 페이지 링크 번호 출력
for ($i=1; $i<=$total_page; $i++)
{
if ($page == $i) // ���� ������ ��ȣ ��ũ ����
{
echo "<b> $i </b>";
}
else
{
echo "<a href='memo.php?page=$i'> $i </a>";
}
}
?>
다음 ▶</div>
</div> <!-- end of ripple -->
</div> <!-- end of col2 -->
</div> <!-- end of content -->
</div> <!-- end of wrap -->
</body>
</html>
The SQL doesn't like doing maths in the limit clause. Do it first in PHP:
$sql2 = "select * from phptest.memo order by num desc limit $start," . ($start+$scale);

AJAX pagination not working properly after new entry

I am having a main page "landing.php", here in a div i am calling another page using ajax function "fetch_pages.php". In fetch_pages.php, i am loading data from db as 5 records at a time, when the user reaches the end of page then next 5 records are displayed. Thats working perfectly.
But in landing.php, when i enter a new record and reload the div, then the div content becomes blank, it doesn't show the latest content, after refreshing the full page manually then its again shows all the records. Can't understand whats wrong, kindly help.
landing.php page
<div class="mainsection">
<div>
<div class="pull-left postimage"><?php echo "<img src=profile_pic/".$ProfilePic ." />"; ?></div>
<div class="pull-left posttext">
<div class="postname"><?php echo $Name; ?></div>
<p><?php echo $UT." - ".$Designation." - ".$Company; ?></p></div>
<textarea id="posting" name="posting" rows="2" cols="50" placeholder="Share something here..."></textarea>
<div class="clear"></div>
<hr>
</div>
<div class="fileUpload btn btn-default">
<span><i class="fa fa-camera-retro" style="margin-right: 6px;" aria-hidden="true"></i>Upload Image</span>
<input type="file" class="upload" />
</div>
<div>
<input class="postall btn btn-primary pull-right" type="submit" onClick="UserPost()" value="Post">
</div>
<div class="clear"></div>
</div>
<!-- Loading User Posts -->
<div id="mainsectionID">
<div id="results"><!-- results appear here as list --></div>
</div>
<script>
(function($){
$.fn.loaddata = function(options) {// Settings
var settings = $.extend({
loading_gif_url : "images/ajax-loader.gif", //url to loading gif
end_record_text : 'No more records found!', //no more records to load
data_url : 'fetch_pages.php', //url to PHP page
start_page : 1 //initial page
}, options);
var el = this;
loading = false;
end_record = false;
contents(el, settings); //initial data load
$(window).scroll(function() { //detact scroll
if($(window).scrollTop() + $(window).height() >= $(document).height()){ //scrolled to bottom of the page
contents(el, settings); //load content chunk
}
});
};
//Ajax load function
function contents(el, settings){
var load_img = $('<img/>').attr('src',settings.loading_gif_url).addClass('loading-image'); //create load image
var record_end_txt = $('<div/>').text(settings.end_record_text).addClass('end-record-info'); //end record text
if(loading == false && end_record == false){
loading = true; //set loading flag on
el.append(load_img); //append loading image
$.post( settings.data_url, {'page': settings.start_page}, function(data){ //jQuery Ajax post
if(data.trim().length == 0){ //no more records
el.append(record_end_txt); //show end record text
load_img.remove(); //remove loading img
end_record = true; //set end record flag on
return; //exit
}
loading = false; //set loading flag off
load_img.remove(); //remove loading img
el.append(data); //append content
settings.start_page ++; //page increment
})
}
}
})(jQuery);
$("#results").loaddata(); //load the results into element
</script>
fetch_pages.php code-
<?php
session_start();
include 'db.php'; //include config file
$UserID=$_SESSION['uid'];
$UserType=$_SESSION['utype'];
$GLOBALS['lks']=0;
$GLOBALS['cmnts']=0;
$GLOBALS['disabled']="";
//sanitize post value
$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
//throw HTTP error if page number is not valid
if(!is_numeric($page_number)){
header('HTTP/1.1 500 Invalid page number!');
exit();
}
//get current starting point of records
$position = (($page_number-1) * $item_per_page);
?>
<!---post start -->
<?php
//fetch records using page position and item per page.
$results = $linkID1->query("select slno,posts,img_link,video_link,likes,comments,shares,post_date,post_time,UserID from user_posts where UserID='$UserID' or UserID in(select MyFriendsUserID from user_connections where MyUserID='$UserID') or UserID in(select MyUserID from user_connections where MyFriendsUserID='$UserID') order by slno desc LIMIT $position, $item_per_page")
or
die(mysqli_error());
//output results from database
?>
<?php
while($row = mysqli_fetch_array($results))
{ //fetch values
$CUID=$row['UserID'];
$stmt = $linkID1->prepare("select Name,Company,Designation,UserType from user_details where UserID=?");
$stmt->bind_param("s", $CUID);
$stmt->execute();
$stmt->bind_result($Name2,$Company2,$Designation2,$UType);
$stmt->fetch();
$stmt->close();
$UT2='';
if($UType=='A')
{
$UT2='Advertiser';
}
else if($UType=='P')
{
$UT2='Publisher';
}
$stmt = $linkID1->prepare("select ProfilePic from user_picture where UserID=?");
$stmt->bind_param("s", $CUID);
$stmt->execute();
$stmt->bind_result($PPic);
$stmt->fetch();
$stmt->close();
?>
<div class="mainsection">
<div>
<div class="pull-left postimage"><?php echo "<img src=profile_pic/".$PPic ." />"; ?></div>
<div class="pull-left posttext">
<div class="postname"><?php echo $Name2; ?></div>
<p><?php echo $UT2." - ".$Designation2." - ".$Company2; ?></p></div>
<div class="clear"></div>
<div class="postdowntxt"><p><?php echo $row['posts']; ?></p></div>
<hr>
</div>
<div class="btnclasess" id="likescommentID<?php echo $row[slno]; ?>">
<div class="likescomment"><?php dataLC($linkID1, $row['slno'],$CUID); ?><a style="padding-right: 7px" href="#"><?php if($GLOBALS['lks']==0){echo '';}else{ echo $GLOBALS['lks']." Likes"; } ?></a><?php if($GLOBALS['cmnts']==0){echo '';}else{ echo $GLOBALS['cmnts']." Comments"; } ?></div>
<div class="pull-left likebtn"><button <?php echo $disabled; ?> class="btn" id="likeButton<?php echo $row[slno]; ?>" onClick="connect(<?php echo $row[slno]; ?>)"><i class="fa fa-thumbs-up" style="margin-right: 6px;"></i>Like</button></div>
<button class="pull-left btnhideshow show_hide" data-toggle="collapse" data-target="#demo<?php echo $row['slno']; ?>"><li class="fa fa-comments show_hide" style="margin-right: 6px;"></li>Comment</button>
<button class="pull-left btnhideshow show_hide"><li class="fa fa-share-alt show_hide" style="margin-right: 6px;"></li>Share</button>
<div class="clear"></div>
<div class="clear"></div>
</div>
<!-- Display All Comments -->
<div id="myModal<?php echo $row['slno']; ?>" class="modal">
<div id="DialogDiv<?php echo $row['slno']; ?>">
<!-- Modal content -->
<div class="modal-content" id="modalDialog<?php echo $row['slno']; ?>">
<p class="popupheading"><?php if($GLOBALS['cmnts']==0){echo '';}else{ echo $GLOBALS['cmnts']." Comments"; } ?></p>
<?php
$result2 = $linkID1->query("select upc.slno,upc.Comment,upc.CommentedUserID,up.ProfilePic from user_posts_comments upc join user_picture up on upc.CommentedUserID=up.UserID where PostID='$row[slno]' order by upc.slno")
or
die(mysqli_error());
while($row2 = mysqli_fetch_array($result2))
{
?>
<div class="pull-left commnetprofile"><?php echo "<img src=profile_pic/".$row2['ProfilePic']." />"; ?></div>
<div class="pull-right commentextstyle commentandreply">
<?php echo $row2['Comment']; ?>
</div>
<div class="pull-left likebtn"><i class="fa fa-reply" style="margin-right: 6px;"></i>Reply</div>
<!--<div class="pull-left likebtn"><i class="fa fa-thumbs-up" style="margin-right: 6px;"></i>Like</div>-->
<div class="clear"></div>
<div id="nReply2<?php echo $row2['slno']; ?>" class="collapse">
<div>
<input class="replybox" type="text" id="nReplyBox2<?php echo $row2['slno']; ?>" onkeyup="enter_reply2(<?php echo $row2['slno']; ?>,<?php echo $CUID; ?>,<?php echo $row['slno']; ?>);">
</div>
</div>
<div class="clear"></div>
<!-- Nested Comments Starts -->
<div id="NestedCmntsDialog" class="nestedcmnts">
<?php
$result3 = $linkID1->query("select upcr.slno,upcr.PostID,upcr.ReplyTo,upcr.ReplyBy,upcr.Comments,up.ProfilePic from user_posts_comments_reply upcr join user_picture up on upcr.ReplyBy=up.UserID where upcr.PostID='$row2[slno]' and (upcr.ReplyTo='$row2[CommentedUserID]' or upcr.ReplyBy='$row2[CommentedUserID]') order by upcr.slno")
or
die(mysqli_error());
while($row3 = mysqli_fetch_array($result3))
{
?>
<div class="pull-left commnetprofile"><?php echo "<img src=profile_pic/".$row3['ProfilePic']." />"; ?></div>
<div class="pull-right commentextstyle commentandreply">
<?php echo $row3['Comments']; ?>
</div>
<div class="pull-left likebtn"><i class="fa fa-reply" style="margin-right: 6px;"></i>Reply</div>
<div class="clear"></div>
<div id="nReply2<?php echo ($row3['slno'] * $row3['slno'])+$row3['PostID']; ?>" class="collapse">
<div>
<input class="replybox" type="text" id="nReplyBox2<?php echo ($row3['slno'] * $row3['slno'])+$row3['PostID']; ?>" onkeyup="enter_nested_reply2(<?php echo $row3['slno']; ?>,<?php echo $row3['ReplyBy']; ?>,<?php echo $row['slno']; ?>,<?php echo $row3['PostID']; ?>);">
</div>
</div>
<!--<div class="pull-left likebtn"><i class="fa fa-thumbs-up" style="margin-right: 6px;"></i>Like</div>-->
<div class="clear"></div>
<?php
}
?>
</div>
<!-- Nested Comments Ends -->
<?php
}
?>
<div class="invidone">Close</div>
</div>
</div>
</div>
<!-- Display All Comments -->
<div class="slidingDiv collapse" id="demo<?php echo $row['slno']; ?>">
<div class="viewallcomments">View All Comments</div>
<div class="allcomment" id="commentsLoad<?php echo $row['slno']; ?>">
<?php
$result2 = $linkID1->query("select upc.slno,upc.Comment,upc.CommentedUserID,up.ProfilePic from user_posts_comments upc join user_picture up on upc.CommentedUserID=up.UserID where upc.PostID='$row[slno]' order by upc.slno desc limit 3")
or
die(mysqli_error());
while($row2 = mysqli_fetch_array($result2))
{
?>
<!-- Showing Top 3 Comments -->
<div id="nestedReplyDiv<?php echo $row['slno']; ?>">
<div class="pull-left commnetprofile"><?php echo "<img src=profile_pic/".$row2['ProfilePic']." />"; ?></div>
<div class="pull-right commentextstyle commentandreply">
<?php echo $row2['Comment']; ?>
</div>
<div class="pull-left likebtn"><i class="fa fa-reply" style="margin-right: 6px;"></i>Reply</div>
<div class="clear"></div>
<div id="nReply<?php echo $row2['slno']; ?>" class="collapse">
<div>
<input class="replybox" type="text" id="nReplyBox<?php echo $row2['slno']; ?>" onkeyup="enter_reply(<?php echo $row2['slno']; ?>,<?php echo $CUID; ?>);">
</div>
</div>
<!--<div class="pull-left likebtn"><i class="fa fa-thumbs-up" style="margin-right: 6px;"></i>Like</div>-->
<div class="clear"></div>
<!-- Nested Comments Starts -->
<div id="NestedCmnts" class="nestedcmnts">
<?php
$result3 = $linkID1->query("select upcr.slno,upcr.PostID,upcr.ReplyTo,upcr.ReplyBy,upcr.Comments,up.ProfilePic from user_posts_comments_reply upcr join user_picture up on upcr.ReplyBy=up.UserID where upcr.PostID='$row2[slno]' and (upcr.ReplyTo='$row2[CommentedUserID]' or upcr.ReplyBy='$row2[CommentedUserID]') order by upcr.slno")
or
die(mysqli_error());
while($row3 = mysqli_fetch_array($result3))
{
?>
<div class="pull-left commnetprofile"><?php echo "<img src=profile_pic/".$row3['ProfilePic']." />"; ?></div>
<div class="pull-right commentextstyle commentandreply">
<?php echo $row3['Comments']; ?>
</div>
<div class="pull-left likebtn"><i class="fa fa-reply" style="margin-right: 6px;"></i>Reply</div>
<div class="clear"></div>
<div id="nReply<?php echo ($row3['slno'] * $row3['slno'])+$row3['PostID']; ?>" class="collapse">
<div>
<input class="replybox" type="text" id="nReplyBox<?php echo ($row3['slno'] * $row3['slno'])+$row3['PostID']; ?>" onkeyup="enter_nested_reply(<?php echo $row3['slno']; ?>,<?php echo $row3['ReplyBy']; ?>,<?php echo $row['slno']; ?>,<?php echo $row3['PostID']; ?>);">
</div>
</div>
<!--<div class="pull-left likebtn"><i class="fa fa-thumbs-up" style="margin-right: 6px;"></i>Like</div>-->
<div class="clear"></div>
<?php
}
?>
</div>
<!-- Nested Comments Ends -->
</div>
<?php
}
?>
</div>
<textarea id="commentarea<?php echo $row[slno]; ?>" class="secondtextareay pull-left" rows="2" cols="50" placeholder="Post comments here..." onkeyup="enter_comment(<?php echo $row['slno']; ?>,<?php echo $CUID; ?>);"></textarea>
<!--<div class="fileUpload second_fileupload btn btn-default pull-left">
<span><i class="fa fa-camera-retro" style="margin-right: 6px;" aria-hidden="true"></i></span>
<input type="file" class="upload" />
</div>-->
<div class="clear"></div>
</div>
</div>
<?php
}
?>
<!--post end-->
<?php
function dataLC($linkID1, $val, $CUID)
{
$UserID=$CUID;
$LgUserID=$_SESSION['uid'];
$stmt = $linkID1->prepare("select likes,comments from user_posts where slno=?");
$stmt->bind_param("s", $val);
$stmt->execute();
$stmt->bind_result($lksD,$cmntsD);
$stmt->fetch();
$stmt->close();
$GLOBALS['lks']=$lksD;
$GLOBALS['cmnts']=$cmntsD;
$stmt = $linkID1->prepare("select count(slno) from user_posts_likes where MyUserID=? and FrUserID=? and PostID=?");
$stmt->bind_param("sss", $UserID,$UserID,$val);
$stmt->execute();
$stmt->bind_result($cnt);
$stmt->fetch();
$stmt->close();
if($cnt>=1)
{
$GLOBALS['disabled']="disabled";
}
else
{
$GLOBALS['disabled']="enabled";
}
$stmt = $linkID1->prepare("select count(slno) from user_posts_likes where MyUserID=? and FrUserID=? and PostID=?");
$stmt->bind_param("sss", $UserID,$LgUserID,$val);
$stmt->execute();
$stmt->bind_result($cnt2);
$stmt->fetch();
$stmt->close();
if($cnt2>=1)
{
$GLOBALS['disabled']="disabled";
}
else
{
$GLOBALS['disabled']="enabled";
}
$stmt = $linkID1->prepare("select count(slno) from user_posts_likes where MyUserID=? and FrUserID=? and PostID=?");
$stmt->bind_param("sss", $LgUserID,$UserID,$val);
$stmt->execute();
$stmt->bind_result($cnt3);
$stmt->fetch();
$stmt->close();
if($cnt3>=1)
{
$GLOBALS['disabled']="disabled";
}
else
{
$GLOBALS['disabled']="enabled";
}
}
?>
<script>
$('.btn').on('click', function(e)
{
$(this).prop('disabled',true); });
</script>
<script>
function UserPost() {
var x = document.getElementById('posting').value;
var timezone_offset_minutes = new Date().getTimezoneOffset();
timezone_offset_minutes = timezone_offset_minutes == 0 ? 0 : -timezone_offset_minutes;
$.ajax({
type: "POST",
url: "user-post.php?p="+x+"&tz="+timezone_offset_minutes,
success: function(data) {
$("#mainsectionID").load(" #mainsectionID");
document.getElementById('posting').value='';
}
});
}
</script>
<script type="text/javascript">
function connect(num) {
$.ajax({
type: "POST",
url: "user-likes.php?id="+num,
success: function(data) {
if(data=='1')
{
$("#likescommentID"+num).load(" #likescommentID"+num);
}
}
});
}
function enter_comment(postid,userpostedid) {
if (event.keyCode == 13 && event.shiftKey) {
// shift+enter pressed
}
else if(event.keyCode == 13){
//enter key pressed
var cmnt = document.getElementById('commentarea'+postid).value;
$.ajax({
type: "POST",
url: "user-comments.php?id="+postid+"&cmnt="+cmnt,
success: function(data2) {
if(data2=='1')
{
$("#commentsLoad"+postid).load(" #commentsLoad"+postid);
$("#likescommentID"+postid).load(" #likescommentID"+postid);
}
}
});
document.getElementById('commentarea'+postid).value='';
}
else{
//nothing
}
}
</script>
<script type="text/javascript">
function enter_reply(slno,userpostedid) {
if (event.keyCode == 13 && event.shiftKey) {
// shift+enter pressed
}
else if(event.keyCode == 13){
//enter key pressed
var cmnt = document.getElementById('nReplyBox'+slno).value;
$.ajax({
type: "POST",
url: "user-comments-reply.php?id="+slno+"&cmnt="+cmnt,
success: function(data2) {
if(data2=='1')
{
$("#commentsLoad"+slno).load(" #commentsLoad"+slno);
}
}
});
document.getElementById('nReplyBox'+slno).value='';
}
else{
//nothing
}
}
function enter_reply2(slno,userpostedid,dno) {
if (event.keyCode == 13 && event.shiftKey) {
// shift+enter pressed
}
else if(event.keyCode == 13){
//enter key pressed
var cmnt = document.getElementById('nReplyBox2'+slno).value;
$.ajax({
type: "POST",
url: "user-comments-reply.php?id="+slno+"&cmnt="+cmnt,
success: function(data2) {
if(data2=='1')
{
$("#DialogDiv"+dno).load(" #DialogDiv"+dno);
//$("#modalDialog"+dno).load(" #modalDialog"+dno);
}
}
});
document.getElementById('nReplyBox2'+slno).value='';
}
else{
//nothing
}
}
</script>
<script type="text/javascript">
function enter_nested_reply(slno,userpostedid,divNo,pid) {
if (event.keyCode == 13 && event.shiftKey) {
// shift+enter pressed
}
else if(event.keyCode == 13){
//enter key pressed
var tot=(slno*slno)+pid;
var cmnt = document.getElementById('nReplyBox'+tot).value;
$.ajax({
type: "POST",
url: "user-comments-reply-nested.php?id="+slno+"&cmnt="+cmnt+"&upid="+userpostedid,
success: function(data2) {
if(data2=='1')
{
$("#nestedReplyDiv"+divNo).load(" #nestedReplyDiv"+divNo);
}
}
});
document.getElementById('nReplyBox'+tot).value='';
}
else{
//nothing
}
}
function enter_nested_reply2(slno,userpostedid,divNo,pid) {
if (event.keyCode == 13 && event.shiftKey) {
// shift+enter pressed
}
else if(event.keyCode == 13){
//enter key pressed
var tot=(slno*slno)+pid;
var cmnt = document.getElementById('nReplyBox2'+tot).value;
$.ajax({
type: "POST",
url: "user-comments-reply-nested.php?id="+slno+"&cmnt="+cmnt+"&upid="+userpostedid,
success: function(data2) {
if(data2=='1')
{
$("#DialogDiv"+divNo).load(" #DialogDiv"+divNo);
//$("#modalDialog"+divNo).load(" #modalDialog"+divNo);
}
}
});
document.getElementById('nReplyBox2'+tot).value='';
}
else{
//nothing
}
}
</script>
<script>
function LoadComment(num) {
var modal2 = document.getElementById('myModal'+num);
var span2 = document.getElementById("close3");
span2.onclick = function() {
modal2.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal2) {
modal2.style.display = "none";
}
}
var x = document.getElementById('myBtn2');
modal2.style.display = "block";
}
</script>
Problem resolved. Called the pagination again in the success method of ajax.

javascript executing php code

i have a php web application project ... and i want to implement a javascript onclick code ..
for example :
when user clicks follow this post ... the MySQL query inserts into database that the user followed this ... so the page is refreshed and after that it will appear as FOLLOWED ..
what's the javascript code needed to do this ... or is there any example may fit ??
here's a sample code
<div id="main_content">
<?php
if(isset($_GET['et']))
{
$et = $_GET['et'];
}
$result = mysql_query("select * from events where event_type =$et") ;
require_once('queries/category_extract.php') ;
?>
<div id="body_content">
<div id="event_tag">
<a><?php echo $cattitle["categ_title"]?>s</a>
</div>
<?php
while($row=mysql_fetch_array($result) )
{
require('queries/followers_extract.php')
?>
<div id="postpreview">
<div id="postpreview_up">
<div id="postpreview_up_left">
<div id="postpreview_up_left_left">
<a>Event Title :</a>
</div>
<div id="postpreview_up_left_right">
<a><?php echo $row["event_title"] ?></a>
</div>
</div>
<div id="postpreview_up_right">
<img src="images/read_more.gif" />
</div>
</div>
<div id="postpreview_bottom">
<div id="postpreview_bottom_left">
<div id="postpreview_bottom_left_left">
<a>Date :</a>
</div>
<div id="postpreview_bottom_left_right">
<a><?php echo $row["event_date"] ?></a>
</div>
</div>
<div id="postpreview_bottom_right">
<div id="postpreview_bottom_right_left">
<?php
if($follower['follower_id'] ==NULL){echo " <img src='images/follow_button.jpg' /> " ; }
else { echo " <img src='images/follow_closed.jpg' /> " ;}
?>
</div>
<div id="postpreview_bottom_right_right">
<?php
if($follower['follower_id'] !=NULL){ echo " <img src='images/following_button.jpg' /> " ; }
else { echo " <img src='images/following_Closed.jpg' /> " ;}
?>
</div>
<div id="postpreview_bottom_right_right">
<?php
if($follower['follower_id'] !=NULL){ echo " <img src='images/unfollow_button.jpg' /> " ; }
else { echo " <img src='images/unfollow_closed.jpg' /> " ;}
?>
</div>
</div>
</div>
</div>
<div id="splitter"></div>
<?php
}
?>
<!--End Of Post Preview-->
<!--End Of Post Preview-->
ok go for this: http://www.9lessons.info/2009/04/exactly-twitter-like-follow-and-remove.html
you have to learn the basics as i read.

Categories