YaWK  24.1
Yet another WebKit
vote-down.php
Go to the documentation of this file.
1 <?php
2 include '../../../classes/db.php';
3 if (!isset($db)) { $db = new \YAWK\db(); }
4 include '../../../classes/sys.php';
5 include '../classes/blog.php';
6 $voteDown = $_POST['voteDown'];
7 $itemid = $_POST['itemid'];
8 // get votes from table...
9 $res = $db->query("SELECT voteDown FROM {blog_items} WHERE id ='" . $itemid . "'");
10 $votes = mysqli_fetch_row($res);
11 if (!empty($votes[0])) {
12  $votes = $votes[0];
13 }
14 else {
15  $votes = 0;
16 }
17 
18 // add vote from user to existing votes
20 
21 // update database with new votes
22 $res = $db->query("UPDATE {blog_items} SET voteDown = '".$votes."' WHERE id = '".$itemid."'");
23 if ($res){
24  $html = "Update erfolgreich!";
25 }
26 else {
27  $html = \YAWK\alert::draw("danger", "Ooops!", "This should not happen. Your like could not be set. Please try again!","","2500");
28 }
29 echo $html;
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30
$votes
Definition: vote-down.php:10
$res
Definition: vote-down.php:9
$voteDown
Definition: vote-down.php:6
$itemid
Definition: vote-down.php:7