Advertisement
Zajkiss

like

Dec 7th, 2016
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2. $db=  new PDO('mysql:host=localhost;dbname=xxx','xxx','xxx');
  3.      //gauname visus turnyrus
  4.      $posts=$db->prepare("SELECT * FROM turnyrai");
  5.      $posts->execute();
  6.      //tikrinam ar yra postu
  7.      if($posts->rowCount() > 0)
  8.      {
  9.          while($fetch = $posts->fetch(PDO::FETCH_ASSOC))
  10.          {
  11.              $id = $fetch['id'];
  12.              $pavadinimas = $fetch['pav'];
  13.              $aprasymas = $fetch['aprasymas'];
  14.              $data = $fetch['data'];
  15.              $laikas = $fetch['laikas'];
  16.              $img = $fetch['img'];
  17.              $tipas = $fetch['tipas'];
  18.              
  19.               ?>
  20.                <h3 style="border-bottom: 1px solid #ddd;"><a href="" style="color: #4aaee7;"><?php echo $pavadinimas; ?></a></h3>
  21.                <p><?php echo $aprasymas;?></p>
  22.                    <?php
  23.  
  24. $uid=$_SESSION['id'];
  25. $sql=$db->prepare("SELECT * FROM fdlikes WHERE pid=$id and user=$uid");
  26. $sql->execute(array($id, $uid));
  27. if($sql->rowCount()==1){
  28.  echo '<a href="#" class="like" id="'.$pid.'" title="Unlike">Unlike</a>';
  29. }else{
  30.  echo '<a href="#" class="like" id="'.$pid.'" title="Like">Like</a>';
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement