46 lines
778 B
PHP
46 lines
778 B
PHP
<?php
|
|
require_once('data.php');
|
|
?>
|
|
|
|
<?php
|
|
|
|
$db = dbVerbindungErzeugen();
|
|
|
|
$id = $_GET["id"];
|
|
$typ = $_GET["typ"];
|
|
|
|
if ($typ == "idee") {
|
|
$sql = "SELECT likes FROM idee WHERE id = $id";
|
|
$resultat = $db->query($sql);
|
|
$likeCount = $resultat ->fetchColumn();
|
|
$likeCount += 1;
|
|
|
|
|
|
|
|
|
|
$sql = "UPDATE idee SET likes=? WHERE id=?";
|
|
$stmt = $db->prepare($sql);
|
|
$stmt->execute(array($likeCount, $id));
|
|
|
|
} 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);
|
|
|
|
|
|
|
|
?>
|