Guest User

Like Script by Steff :)

a guest
May 17th, 2012
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.69 KB | None | 0 0
  1. <?php
  2.  
  3. $likes_query1 = mysql_query("Select * from likes where news_id = '".$ausgabe['id']."'");
  4. $liked1_query = mysql_query("select count(id) from likes where news_id = '".$ausgabe["id"]."' and like2 = '1'");
  5. $liked2_query = mysql_query("select count(id) from likes where news_id = '".$ausgabe["id"]."' and like2 = '0'");
  6. $liked3_query = mysql_query("select count(id) from likes where news_id = '".$ausgabe["id"]."'");
  7. $ipcheck = mysql_query("Select count(id) from likes where news_id = '".$ausgabe['id']."' and ipadress = '".$_SERVER['REMOTE_ADDR']."'");
  8.  
  9. $ipcheck1 = mysql_fetch_array($ipcheck);
  10. $likes = mysql_fetch_assoc($likes_query1);
  11. $liked1 = mysql_fetch_array($liked1_query);
  12. $liked2 = mysql_fetch_array($liked2_query);
  13. $liked3 = mysql_fetch_array($liked3_query);
  14.  
  15. $rechnung1 = 100/$liked3[0];
  16. $rechnung4 = $rechnung1*$liked1[0];
  17. $rechnung5 = $rechnung1*$liked2[0];
  18.  
  19. if(isset($_POST['true']))
  20. {
  21.   mysql_query("INSERT INTO `likes` (ipadress,like2,date,news_id) VALUES ('".$_SERVER['REMOTE_ADDR']."', '1', '".time()."', '".$ausgabe["id"]."')");
  22.   header("Location: /");
  23. }
  24. else
  25. if(isset($_POST['false']))
  26. {
  27.   mysql_query("INSERT INTO `likes` (ipadress,like2,date,news_id) VALUES ('".$_SERVER['REMOTE_ADDR']."', '0', '".time()."', '".$ausgabe["id"]."')");
  28.   header("Location: /");
  29. }
  30. ?>
  31.  
  32. <style>
  33.  
  34. .watch-sparkbars {
  35.     width: 250px;
  36.     height:4px;
  37.     margin:2px 0;
  38.     border:1px solid #ccc;
  39.     overflow:hidden;
  40.     -webkit-border-radius:3px;
  41.     -moz-border-radius:3px;
  42.     border-radius:3px
  43. }
  44.  
  45. .watch-sparkbar-likes{
  46.     float:left;
  47.     height:4px;
  48.     border-right:1px solid #fff;
  49.     background:#060
  50. }
  51.  
  52. .watch-sparkbar-dislikes{
  53.     float:right;
  54.     height:4px;
  55.     margin-right:-1px;
  56.     background:#c00
  57. }
  58.  
  59. </style>
  60.  
  61. <center>
  62.   <br />
  63.   <div class="watch-sparkbars">
  64.           <div class="watch-sparkbar-likes" style="width: <?php echo $rechnung4; ?>%"></div>
  65.           <div class="watch-sparkbar-dislikes" style="width: <?php echo $rechnung5; ?>%"></div>
  66.         </div><br />
  67.        
  68.         <?php if($ipcheck1[0] == 0) { ?>
  69.         <form method="post"><input type="hidden" name="true"><input type="submit" style="cursor: pointer; height: 17px;width: 67px;background-image:url('./like.png'); border: none;" value=""></form>
  70.         <form method="post"><input type="hidden" name="false"><input type="submit" style="cursor: pointer; height: 17px;width: 67px;background-image:url('./unlike.png'); border: none;" value=""></form><?php } ?>
  71.         <span style="color: black;" class="watch-likes-dislikes">
  72. Gefällt <span style="color: black;" class="likes"><?php echo intval($liked1[0]); ?></span>, gefällt <span style="color: black;" class="dislikes"><?php echo intval($liked2[0]); ?></span> nicht
  73.         </span>
  74.        
  75.         </center>
Advertisement
Add Comment
Please, Sign In to add comment