Advertisement
koki2000

like_feldolgozo

Mar 5th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2. require_once 'kapcsolat.php';
  3. /*
  4. if(isset($_GET['newsid'], $_GET['userid'])){
  5.     $newsid=$_GET['newsid'];
  6.     $userid=$_GET['userid'];
  7.     $check = $db->prepare("SELECT `id`, `userid` FROM `likeok` WHERE `id`=? and `userid`=?");
  8.     $check->bind_param('si', $newsid, $userid);
  9.     $check->execute();
  10.     $check->bind_result($id, $userid);
  11.     while($check->fetch()){
  12.         echo $id.' '.$userid.'<br />';
  13.     }
  14.     echo 'hello kitty';
  15. }
  16. */
  17.  
  18. if(isset($_GET['news'], $_GET['user'])){
  19.  
  20.     $newsid = $_GET['news'];
  21.     $userid = $_GET['user'];
  22.  
  23.     $check = $db->prepare("SELECT `id`, `userid`, `likeoltad`, `like` FROM `likeok` WHERE `id`=? and `userid`=?");
  24.     $check->bind_param('si', $newsid, $userid);
  25.     $check->execute();
  26.     $check->bind_result($id, $userid, $likeoltad, $like);
  27.  
  28.     while($check->fetch()){
  29.         echo 'id: '.$id.' userid: '.$userid.' likeoltad: '.$likeoltad.' LIKE: '.$like.'<br/>';
  30.        
  31.     }
  32.    
  33.     if ($likeoltad=='0'){
  34.         $likeoltad++;
  35.         $like++;
  36.     }else{
  37.         $likeoltad--;
  38.         $like--;
  39.     }
  40.  
  41.     if ($db->query("UPDATE `likeok` SET `likeoltad`='$likeoltad', `like`='$like' WHERE `id` = '$newsid'")) {
  42.         echo $db->affected_rows;
  43.     }
  44.    
  45.    
  46. }
  47.  
  48. header('Location: ./like.php');
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement