Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if($_REQUEST['tutid'] && $_REQUEST['cid']){
- //make array to cid to get id
- foreach($_REQUEST['cid'] as $key => $value){
- $res = mysqli_query($dbh,"SELECT * FROM test WHERE id =".$value." AND page_id=".$_REQUEST['tutid']." ORDER BY id DESC LIMIT 1") or die(mysqli_error($dbh));
- $rows = mysqli_fetch_assoc($res);
- $row[] = array_map('utf8_encode', $rows); //line 80
- $data = array();
- $data['id'] = $rows['id'];
- $data['username'] = $rows['username'];
- $data['description'] = $rows['description'];
- //etc all
- //do something
- if (!empty($data)) {
- echo json_encode($data);
- flush();
- exit(0);
- }
- }
- }
- if (!empty($rows)) {
- $row[] = array_map('utf8_encode', $rows);
- }
- <div class="case" data-post-id=".$id."></div>
- <div class="case" data-post-id=".$id."></div>
- // etc more
- <script type="text/javascript" charset="utf-8">
- var CID = [];
- $('div[data-post-id]').each(function(i){
- CID[i] = $(this).data('post-id');
- });
- function addrep(type, msg){
- CID.forEach(function(id){
- $("#newreply"+id).append("<div class='"+ type +""+ msg.id +"'><ul>"+ msg.description +"</ul></div>");
- });
- }
- var tutid = '<?php echo $tutid; ?>';
- function waitForRep(){
- $.ajax({
- type: "GET",
- url: "/server.php",
- cache: false,
- data: {
- tutid : tutid,
- // this way array containing all ID's can be sent:
- 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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement