In my php code I have dynamic php $id for each post like in my index.php page have <div id=post'.$id.'>
display at browser console as
<div id=post11>
<div id=post12>
<div id=post13>
etc more else.
Now I want to sent my above post ids in my server.php file to make query by id (if any id match in sql) and those id will sent by Javascript VAR CID = ''
from index.php page.
So my I want my javascript sent data like
VAR CID = 11 or 12 or 13 or anything else to match in sql;
And my server.php file get those id by
$_REQUEST['cid']= 11 or 12 or 13 or others more else to match in sql;
then make query to find if any id match in sql
WHERE id =".$_REQUEST['cid']." AND page_id=".$_REQUEST['tutid']." ORDER BY id DESC
Here is my related script:
Update script (A server and Clint side regular update script)
:
<script type="text/javascript" charset="utf-8">
var CID = ''; // Post id
var tutid = '<?php echo $pageid; ?>'; // Particular page id
function addrep(type, msg){
$("#newreply"+CID).append("");
}
function waitForRep(){
$.ajax({
type: "GET",
url: "server.php",
cache: false,
data: "tutid="+ tutid + "&cid="+ CID,
timeout:15000,
success: function(data){
addrep("postreply", data);
setTimeout(
waitForRep,
15000
);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
setTimeout(
waitForRep,
15000
);
}
});
};
$(document).ready(function(){
waitForRep();
});
</script>
index.php
echo '<div id=post'.$id.'>name: AAAA </div>';
echo '<div id=post'.$id.'>name: BBBB </div>';
echo '<div id=post'.$id.'>name: CCCC </div>';
Server.php
while (true) {
if($_REQUEST['tutid'] && $_REQUEST['cid']){
// make query by $tutid and $cid
}
}