Home How to make specific button disappear
Reply: 0

How to make specific button disappear

user2011
1#
user2011 Published in August 15, 2018, 11:16 am

I am newbie at website programming. This is for my school 'end of the year' project. I need to know how to make upvote/downvote system. I managed to make +1 and -1 buttons for each of my posts, but when I want them to disappear when clicked all of them disappear (instead of only the specific one). The +1 and -1 works for individual posts but my solution does not work. example: When I click button +1 on post id=2 all of +1 buttons disappear and so on. I would like to know the solution for my problem. Thanks in advance

while ($forum = $vysledek->fetch_assoc())
    { 
        if (isset($_SESSION['upvote'])) {
            $type = 'hidden';
        }
        else
        {
            $type = 'button';
        }
         if (isset($_SESSION['downvote'])) {
            $type1 = 'hidden';
        }
        else
        {
            $type1 = 'button';
        }

        ?>

<a href='votes.php?pris=<?php echo $forum['id_prispevek'] ?> & ad_id=1'>
    <input type="<?php echo $type ?>" value="+1"></a>
<a href='votes.php?pris=<?php echo $forum['id_prispevek'] ?> & ad_id=0'>
    <input type="<?php echo $type1 ?>" value="-1"></a>

}

and on votes.php

<?php
  include "pripojeni1.php";
 $var_value = $_GET['ad_id'];
 $prispevek = $_GET['pris'];

if ($var_value == 1) {
 $query = mysqli_query($link,"
UPDATE forum 
  SET votes = votes + 1
   WHERE id_prispevek = '".$prispevek."'
 ");
   header("location:vypisForum.php?var=$prispevek");
   $_SESSION['upvote'] = 1;
 unset($_SESSION['downvote']);



  }
 if ($var_value == 0) {
 $query = mysqli_query($link,"
   UPDATE forum 
     SET votes = votes - 1
  WHERE id_prispevek = '".$prispevek."'
 ");
     header("location:vypisForum.php?var=$prispevek"); 
    $_SESSION['downvote'] = 1;
    unset($_SESSION['upvote']);
 }
 ?>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309723 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO