2022-10-27 17:33:19 +02:00
|
|
|
<?php
|
2022-11-14 16:27:53 +01:00
|
|
|
require_once('data.php');
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$db = dbVerbindungErzeugen();
|
|
|
|
|
|
|
|
$id = $_GET["id"];
|
2022-11-15 14:59:24 +01:00
|
|
|
$typ = $_GET["typ"];
|
|
|
|
|
|
|
|
if ($typ == "idee") {
|
|
|
|
$sql = "SELECT likes FROM idee WHERE id = $id";
|
2022-11-14 16:27:53 +01:00
|
|
|
$resultat = $db->query($sql);
|
|
|
|
$likeCount = $resultat ->fetchColumn();
|
|
|
|
$likeCount += 1;
|
|
|
|
|
2022-10-27 17:33:19 +02:00
|
|
|
|
2022-11-15 14:59:24 +01:00
|
|
|
|
2022-10-27 17:33:19 +02:00
|
|
|
|
|
|
|
$sql = "UPDATE idee SET likes=? WHERE id=?";
|
|
|
|
$stmt = $db->prepare($sql);
|
2022-11-14 16:27:53 +01:00
|
|
|
$stmt->execute(array($likeCount, $id));
|
2022-10-27 17:33:19 +02:00
|
|
|
|
2022-11-15 14:59:24 +01:00
|
|
|
} elseif ($typ == "kommentar"){
|
|
|
|
|
|
|
|
$sql = "SELECT k_likes FROM kommentar WHERE k_id = $id";
|
|
|
|
$resultat = $db->query($sql);
|
|
|
|
$likeCount = $resultat ->fetchColumn();
|
|
|
|
$likeCount += 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "UPDATE kommentar SET k_likes=? WHERE k_id=?";
|
|
|
|
$stmt = $db->prepare($sql);
|
|
|
|
$stmt->execute(array($likeCount, $id));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
echo ($likeCount);
|
|
|
|
|
|
|
|
|
2022-10-27 17:33:19 +02:00
|
|
|
|
|
|
|
?>
|