Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $likes_query1 = mysql_query("Select * from likes where news_id = '".$ausgabe['id']."'");
- $liked1_query = mysql_query("select count(id) from likes where news_id = '".$ausgabe["id"]."' and like2 = '1'");
- $liked2_query = mysql_query("select count(id) from likes where news_id = '".$ausgabe["id"]."' and like2 = '0'");
- $liked3_query = mysql_query("select count(id) from likes where news_id = '".$ausgabe["id"]."'");
- $ipcheck = mysql_query("Select count(id) from likes where news_id = '".$ausgabe['id']."' and ipadress = '".$_SERVER['REMOTE_ADDR']."'");
- $ipcheck1 = mysql_fetch_array($ipcheck);
- $likes = mysql_fetch_assoc($likes_query1);
- $liked1 = mysql_fetch_array($liked1_query);
- $liked2 = mysql_fetch_array($liked2_query);
- $liked3 = mysql_fetch_array($liked3_query);
- $rechnung1 = 100/$liked3[0];
- $rechnung4 = $rechnung1*$liked1[0];
- $rechnung5 = $rechnung1*$liked2[0];
- if(isset($_POST['true']))
- {
- mysql_query("INSERT INTO `likes` (ipadress,like2,date,news_id) VALUES ('".$_SERVER['REMOTE_ADDR']."', '1', '".time()."', '".$ausgabe["id"]."')");
- header("Location: /");
- }
- else
- if(isset($_POST['false']))
- {
- mysql_query("INSERT INTO `likes` (ipadress,like2,date,news_id) VALUES ('".$_SERVER['REMOTE_ADDR']."', '0', '".time()."', '".$ausgabe["id"]."')");
- header("Location: /");
- }
- ?>
- <style>
- .watch-sparkbars {
- width: 250px;
- height:4px;
- margin:2px 0;
- border:1px solid #ccc;
- overflow:hidden;
- -webkit-border-radius:3px;
- -moz-border-radius:3px;
- border-radius:3px
- }
- .watch-sparkbar-likes{
- float:left;
- height:4px;
- border-right:1px solid #fff;
- background:#060
- }
- .watch-sparkbar-dislikes{
- float:right;
- height:4px;
- margin-right:-1px;
- background:#c00
- }
- </style>
- <center>
- <br />
- <div class="watch-sparkbars">
- <div class="watch-sparkbar-likes" style="width: <?php echo $rechnung4; ?>%"></div>
- <div class="watch-sparkbar-dislikes" style="width: <?php echo $rechnung5; ?>%"></div>
- </div><br />
- <?php if($ipcheck1[0] == 0) { ?>
- <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>
- <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 } ?>
- <span style="color: black;" class="watch-likes-dislikes">
- 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
- </span>
- </center>
Advertisement
Add Comment
Please, Sign In to add comment