This is my first time doing pagination with jQuery ajax. I do it like this:
I include file 'GetAllMessages.php' into a div, only if i'm logged in.[works]
I include file 'GetMessages.php' again only if im logged in which tells me how many messages are in database.[works]
When I click on my 'messages' link I open a popup and I get my first four messages from 'GetAllMessages.php'.[works]
At the end of this div i have pages like [1,2,3...] and then with jquery $.ajax function (post method) i go again into 'GetAllMessages.php' but this time I tell the file which page I clicked so it gives me the messages I want next.[doesnt work]
It's like SESSION does not exsist, but if I add 'SESSION_START' at start in 'GetAllMesasages.php' it says its already started on my initial 'GetAllMessages.php' load, but when I click on page link[1,2,3...] the error goes away and it all works.
GetAllMessages.php
<?php
if(isset($_SESSION["uname"])){
include ('config.php');
include ('getMessages.php');
$pages=$messageCount/$messagesPerPage;
if(isset($_POST["page"])){
$page=$_POST["page"];
}else{
$page=1;
}
$startQuery=($page-1)*$messagesPerPage;
$getMessagesQuery = "SELECT * from messages ORDER BY id DESC LIMIT ".$startQuery.",".$messagesPerPage."";
$result = $conn->query($getMessagesQuery);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
$mId=$row["id"];
$mName=$row["name"];
$mEmail=$row["email"];
$mMessage=$row["message"];
$mDate=$row["messageDate"];
$mIsRead=$row["seen"];
$mIsAnswered=$row["answered"];
if($mIsRead==0){
$messageStatus="unread";
$markReadButton="<button class='button1'>Mark as read</button>";
}else if($mIsAnswered==1){
$markReadButton="";
$messageStatus="answered";
}else{
$markReadButton="";
$messageStatus="";
}
echo "
<div class='message ".$messageStatus."' data-messageid='".$mId."'>
<p class='date'>".$mDate."</p>
<p class='sender'>".$mName." - ".$mEmail."</p>
<p class='messageContent'>".$mMessage."</p>
<span class='buttons'>
<button class='reply'>Reply</button>
".$markReadButton."
</span>
</div>";
}
}
}else die();
?>
How to kill a query running by pd.read_sql and connected by sqlalchemy (or mysql.connector)
Radio and checkbox cannot be checked when inside BootStrap Modal
When I make an android build with phonegap, download it on my phone and launch it, it wont make the webservice calls. In fact it wont retrieve the JQuery files from the cdn link that I have in the header.
When editing a row on jqgrid, the cursor automatically enters the left-most editable field. Is there a way to have it default to a particular column, or better yet, to whatever column I click on?.
I have a row of buttons in my Angular. js application that currently open up a new route, showing a new partial view on the page.