Compare commits
1
Commits
noah
..
0e5f580c74
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e5f580c74 |
No files matched your search
+15
-10
@@ -48,17 +48,22 @@ h1 {
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.commentText{
|
.image-preview ._list {
|
||||||
display: inline-block;
|
padding-top: 20px;
|
||||||
padding-right: 20px;
|
|
||||||
}
|
}
|
||||||
|
.image-preview ._item {
|
||||||
p.commentLikeNumber{
|
padding: 0 0 10px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding-right: 20px;
|
text-align: center;
|
||||||
|
vertical-align: top;
|
||||||
|
width: 100px;
|
||||||
|
word-break: break-word;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: normal;
|
||||||
}
|
}
|
||||||
|
.image-preview ._item img {
|
||||||
img.commentLike{
|
display: block;
|
||||||
width: 15px;
|
width: 80px;
|
||||||
display: inline-block;
|
height: 80px;
|
||||||
|
padding: 0 10px 6px;
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,19 @@ dbVerbindungErzeugen()
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>SPINN MIT!</title>
|
<title>SPINN MIT!</title>
|
||||||
<link rel="stylesheet" href="/css/style.css">
|
<link rel="stylesheet" href="/css/style.css">
|
||||||
|
|
||||||
|
|
||||||
|
<script>UPLOADCARE_LOCALE="de"
|
||||||
|
UPLOADCARE_LOCALE_TRANSLATIONS = {
|
||||||
|
buttons: {
|
||||||
|
choose: {
|
||||||
|
files: {
|
||||||
|
other: 'Bild hochladen'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>spinn mit!!</h1>
|
<h1>spinn mit!!</h1>
|
||||||
@@ -29,11 +42,17 @@ dbVerbindungErzeugen()
|
|||||||
|
|
||||||
<div id="idee">
|
<div id="idee">
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="image-preview" id="image-upload">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||||
|
<script src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="js/functions.js"></script>
|
<script src="js/functions.js"></script>
|
||||||
<script src="js/main.js"></script>
|
<script src="js/main.js"></script>
|
||||||
|
|||||||
+66
-259
@@ -28,91 +28,18 @@ fetch(url,
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//LocalLike Objekt erstellen
|
// submit kommentar nicht seite neu laden
|
||||||
|
|
||||||
let localLikes = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
|
||||||
// submit kommentar nicht seite neu laden
|
|
||||||
|
|
||||||
$("#kommentarform").submit(function(e) {
|
$("#kommentarform").submit(function(e) {
|
||||||
console.log("Submitted")
|
console.log("Submitted")
|
||||||
e.preventDefault(); // avoid to execute the actual submit of the form.
|
e.preventDefault(); // avoid to execute the actual submit of the form.
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//LocalStorage erstellen oder auslesen
|
|
||||||
|
|
||||||
if(localStorage.getItem('localLikes')){
|
|
||||||
//likes auslesen
|
|
||||||
|
|
||||||
localLikes = JSON.parse(localStorage.getItem('localLikes'))
|
|
||||||
|
|
||||||
console.log("Stored local Likes:")
|
|
||||||
console.log(localLikes)
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
//LocalLikes leer
|
|
||||||
|
|
||||||
localLikes = {
|
|
||||||
ideen: [],
|
|
||||||
kommentare: []
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("New Local Likes created")
|
|
||||||
console.log(localLikes)
|
|
||||||
|
|
||||||
localStorage.setItem('localLikes',JSON.stringify(localLikes));
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// idee laden
|
||||||
|
|
||||||
|
|
||||||
//LocalStorage Anpassen (Likes hinzufügen oder entfernen)
|
|
||||||
|
|
||||||
|
|
||||||
function chageLocalStorrage(typ, id, addRemove){
|
|
||||||
|
|
||||||
if(typ =="idee"){
|
|
||||||
|
|
||||||
if(addRemove == "add" && !localLikes.ideen.includes(id)){
|
|
||||||
localLikes.ideen.push(id);
|
|
||||||
console.log("like added");
|
|
||||||
console.log(localLikes);
|
|
||||||
}else if(addRemove == "remove" && localLikes.ideen.includes(id)){
|
|
||||||
let index = localLikes.ideen.indexOf(id);
|
|
||||||
localLikes.ideen.splice(index, 1);
|
|
||||||
console.log("like removed");
|
|
||||||
console.log(localLikes);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if(typ == "kommentar"){
|
|
||||||
|
|
||||||
if(addRemove == "add"){
|
|
||||||
localLikes.kommentare.push(id);
|
|
||||||
}else if(addRemove == "remove"){
|
|
||||||
let index = localLikes.kommentare.indexOf(id);
|
|
||||||
localLikes.kommentare.splice(index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
localStorage.setItem('localLikes',JSON.stringify(localLikes));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// IDEE ANZEIGEN
|
|
||||||
|
|
||||||
function ideeAnzeigen(data) {
|
function ideeAnzeigen(data) {
|
||||||
|
|
||||||
@@ -133,7 +60,7 @@ function ideeAnzeigen(data) {
|
|||||||
let likesErstellen = document.createElement("p");
|
let likesErstellen = document.createElement("p");
|
||||||
let likes = document.createTextNode(data.likes + " Likes");
|
let likes = document.createTextNode(data.likes + " Likes");
|
||||||
likesErstellen.appendChild(likes);
|
likesErstellen.appendChild(likes);
|
||||||
likesErstellen.classList.add("likeDisplay");
|
likesErstellen.classList.add("loeschen");
|
||||||
document.getElementById('idee').appendChild(likesErstellen);
|
document.getElementById('idee').appendChild(likesErstellen);
|
||||||
|
|
||||||
let bild = document.createElement("img");
|
let bild = document.createElement("img");
|
||||||
@@ -144,38 +71,20 @@ function ideeAnzeigen(data) {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
|
|
||||||
let ideeLike = document.createElement("img");
|
|
||||||
ideeLike.classList.add("herz");
|
|
||||||
|
|
||||||
|
|
||||||
//check if user has liked Idea before,load proper image and set class
|
let herz = document.createElement("img");
|
||||||
|
herz.src= "../images/herz-0.png";
|
||||||
|
herz.classList.add("herz");
|
||||||
|
herz.classList.add("loeschen");
|
||||||
|
document.getElementById('idee').appendChild(herz);
|
||||||
|
herz.addEventListener('click', function() {
|
||||||
|
herz.src= "../images/herz-1.png";
|
||||||
|
|
||||||
if(localLikes.ideen.includes(data.id)){
|
$.post('system/addLike.php/?id=' + data.id, {}).done(function(response){
|
||||||
ideeLike.src= "../images/herz-1.png";
|
$("#mypar").html(response.amount);
|
||||||
ideeLike.classList.add("liked");
|
|
||||||
}else{
|
|
||||||
ideeLike.src= "../images/herz-0.png";
|
|
||||||
ideeLike.classList.add("unliked");
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('idee').appendChild(ideeLike);
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ideeLike.addEventListener('click', function() {
|
|
||||||
|
|
||||||
if(localLikes.ideen.includes(data.id)){
|
|
||||||
ideeLike.src= "../images/herz-0.png";
|
|
||||||
ideeLike.classList.add("unliked");
|
|
||||||
ideeLike.classList.remove("liked");
|
|
||||||
removeLike("idee", data.id)
|
|
||||||
}else{
|
|
||||||
|
|
||||||
ideeLike.src= "../images/herz-1.png";
|
|
||||||
ideeLike.classList.add("liked");
|
|
||||||
ideeLike.classList.remove("unliked");
|
|
||||||
addLike("idee", data.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -194,82 +103,6 @@ function ideeAnzeigen(data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Like Hinzufügen
|
|
||||||
|
|
||||||
function addLike(typ, id, element){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(typ == "idee"){
|
|
||||||
|
|
||||||
//increment likes in DB
|
|
||||||
$.post('system/addLike.php/?typ=idee&id=' + id, {}).done(function(response){
|
|
||||||
|
|
||||||
|
|
||||||
//neue Likes anzeigen
|
|
||||||
|
|
||||||
$("p.likeDisplay").html(response + " Likes")
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
//add like in LocalStorage
|
|
||||||
chageLocalStorrage("idee", id, "add")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else if(typ == "kommentar"){
|
|
||||||
$.post('system/addLike.php/?typ=kommentar&id=' + id, {}).done(function(response){
|
|
||||||
|
|
||||||
|
|
||||||
element.prev().html(response + " Likes")
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
//add like in LocalStorage
|
|
||||||
chageLocalStorrage("kommentar", id, "add")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeLike(typ, id, element){
|
|
||||||
|
|
||||||
//decrement likes in DB
|
|
||||||
|
|
||||||
if(typ == "idee"){
|
|
||||||
$.post('system/removeLike.php/?typ=idee&id=' + id, {}).done(function(response){
|
|
||||||
|
|
||||||
|
|
||||||
$("p.likeDisplay").html(response + " Likes")
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
chageLocalStorrage("idee", id, "remove")
|
|
||||||
|
|
||||||
}else if(typ == "kommentar"){
|
|
||||||
$.post('system/removeLike.php/?typ=kommentar&id=' + id, {}).done(function(response){
|
|
||||||
|
|
||||||
|
|
||||||
element.prev().html(response + " Likes")
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
chageLocalStorrage("kommentar", id, "remove")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// kommentar formular likesErstellen
|
// kommentar formular likesErstellen
|
||||||
|
|
||||||
function kommentarErstellen(idee_id) {
|
function kommentarErstellen(idee_id) {
|
||||||
@@ -278,7 +111,7 @@ function kommentarErstellen(idee_id) {
|
|||||||
|
|
||||||
let formular = document.createElement("form");
|
let formular = document.createElement("form");
|
||||||
formular.classList.add("formular");
|
formular.classList.add("formular");
|
||||||
formular.setAttribute("action", "../system/kommentarSpeichern.php");
|
formular.setAttribute("action", "https://751068-4.web.fhgr.ch/system/kommentarSpeichern.php");
|
||||||
formular.setAttribute("method", "post");
|
formular.setAttribute("method", "post");
|
||||||
formular.setAttribute("id", "kommentarform");
|
formular.setAttribute("id", "kommentarform");
|
||||||
document.getElementById("idee").appendChild(formular);
|
document.getElementById("idee").appendChild(formular);
|
||||||
@@ -310,7 +143,7 @@ function kommentarErstellen(idee_id) {
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/system/kommentarSpeichern.php",
|
url: "https://751068-4.web.fhgr.ch/system/kommentarSpeichern.php",
|
||||||
data: form.serialize(),
|
data: form.serialize(),
|
||||||
})
|
})
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -320,6 +153,27 @@ function kommentarErstellen(idee_id) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* function installWidgetPreviewMultiple(widget, list) {
|
||||||
|
widget.onChange(function(fileGroup) {
|
||||||
|
list.empty()
|
||||||
|
if (fileGroup) {
|
||||||
|
$.when.apply(null, fileGroup.files()).done(function() {
|
||||||
|
$.each(arguments, function(i, fileInfo) {
|
||||||
|
var src = fileInfo.cdnUrl + '-/scale_crop/160x160/center/'
|
||||||
|
|
||||||
|
list.append($('<div/>', {class: '_item'}).append([$('<img/>', {src: src}), fileInfo.name]))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$(function() {
|
||||||
|
$('.image-preview').each(function() {
|
||||||
|
installWidgetPreviewMultiple(uploadcare.MultipleWidget($(this).children('input')), $(this).children('._list'))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Idee formular erstellen
|
// Idee formular erstellen
|
||||||
@@ -330,7 +184,7 @@ function formularErstellen(koordianten) {
|
|||||||
|
|
||||||
let formular = document.createElement("form");
|
let formular = document.createElement("form");
|
||||||
formular.classList.add("formular");
|
formular.classList.add("formular");
|
||||||
formular.setAttribute("action", "../system/ideeSpeichern.php");
|
formular.setAttribute("action", "https://751068-4.web.fhgr.ch/system/ideeSpeichern.php");
|
||||||
formular.setAttribute("method", "post");
|
formular.setAttribute("method", "post");
|
||||||
formular.setAttribute("id", "form");
|
formular.setAttribute("id", "form");
|
||||||
document.getElementById("idee").appendChild(formular);
|
document.getElementById("idee").appendChild(formular);
|
||||||
@@ -373,97 +227,50 @@ function formularErstellen(koordianten) {
|
|||||||
document.getElementById("form").appendChild(submit_input);
|
document.getElementById("form").appendChild(submit_input);
|
||||||
document.getElementById("form").appendChild(koordinaten_lat);
|
document.getElementById("form").appendChild(koordinaten_lat);
|
||||||
document.getElementById("form").appendChild(koordinaten_lng);
|
document.getElementById("form").appendChild(koordinaten_lng);
|
||||||
|
|
||||||
|
document.getElementById("image-upload").innerHTML = '<input type="hidden" role="uploadcare-uploader" data-public-key="3a3c37e85850c6cfe077" data-multiple="true" data-images-only data-public- data-clearable data-tabs="file camera" data-image-shrink: "1024x1024" data-system-dialog="false"/>';
|
||||||
|
|
||||||
|
// get a widget reference
|
||||||
|
const widget = uploadcare.Widget("[role=uploadcare-uploader]", { multiple: true});
|
||||||
|
|
||||||
|
// listen to the "upload completed" event
|
||||||
|
widget.onUploadComplete(fileGroupInfo => {
|
||||||
|
// get a information about uploaded group
|
||||||
|
// check https://uploadcare.com/docs/file-uploader-api/file-groups/#file-group-info
|
||||||
|
|
||||||
|
for (var i = 0; i < fileGroupInfo.count; i++) {
|
||||||
|
console.log("https://ucarecdn.com/" + fileGroupInfo.uuid + "/nth/" + i + "/-/preview/-/quality/smart/-/format/auto/");
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function kommentareAnzeigen(idee_id){
|
function kommentareAnzeigen(idee_id){
|
||||||
|
|
||||||
|
document.getElementById("kommentare_container").innerHTML = "";
|
||||||
|
|
||||||
$.post("./system/alleKommentareHolen.php/?id=" + idee_id, {}).done(function(comments){
|
let url = "system/alleKommentareHolen.php/?id=" + idee_id;
|
||||||
|
fetch(url)
|
||||||
|
.then((response) => {
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
let k = document.createElement("h3");
|
let k = document.createElement("h3");
|
||||||
let k_text = document.createTextNode("Kommentare:");
|
let k_text = document.createTextNode("Kommentare:");
|
||||||
k.appendChild(k_text);
|
k.appendChild(k_text);
|
||||||
|
k.classList.add("loeschen")
|
||||||
document.getElementById('kommentare_container').appendChild(k);
|
document.getElementById('kommentare_container').appendChild(k);
|
||||||
|
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
let commentArray = JSON.parse(comments);
|
|
||||||
|
|
||||||
|
|
||||||
for (var i = 0; i < commentArray.length; i++) {
|
|
||||||
|
|
||||||
|
|
||||||
let thisComment = commentArray[i];
|
|
||||||
|
|
||||||
|
|
||||||
let kommentarContainer = $("<div>").addClass("comment");
|
|
||||||
|
|
||||||
|
|
||||||
let kommentarText = $("<p>").addClass("commentText");
|
|
||||||
kommentarText.text(thisComment.k_text);
|
|
||||||
kommentarText.appendTo(kommentarContainer);
|
|
||||||
|
|
||||||
let kommentarLikeNumber = $("<p>").text(thisComment.k_likes + " Likes").addClass("commentLikeNumber");
|
|
||||||
kommentarLikeNumber.appendTo(kommentarContainer);
|
|
||||||
|
|
||||||
let kommentarLikeButton = $("<img>").addClass("unliked commentLike")
|
|
||||||
|
|
||||||
|
|
||||||
if(localLikes.kommentare.includes(thisComment.k_id)){
|
|
||||||
kommentarLikeButton.attr("src", "../images/herz-1.png");
|
|
||||||
kommentarLikeButton.addClass("liked");
|
|
||||||
}else{
|
|
||||||
kommentarLikeButton.attr("src", "../images/herz-0.png");
|
|
||||||
kommentarLikeButton.addClass("unliked");
|
|
||||||
}
|
|
||||||
|
|
||||||
kommentarLikeButton.appendTo(kommentarContainer);
|
|
||||||
|
|
||||||
kommentarContainer.appendTo($("#kommentare_container"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kommentarLikeButton.click( function() {
|
|
||||||
|
|
||||||
if(localLikes.kommentare.includes(thisComment.k_id)){
|
|
||||||
kommentarLikeButton.attr("src", "../images/herz-0.png");
|
|
||||||
kommentarLikeButton.addClass("unliked");
|
|
||||||
kommentarLikeButton.removeClass("liked");
|
|
||||||
removeLike("kommentar", thisComment.k_id, $(this))
|
|
||||||
}else{
|
|
||||||
|
|
||||||
kommentarLikeButton.attr("src", "../images/herz-1.png");
|
|
||||||
kommentarLikeButton.addClass("liked");
|
|
||||||
kommentarLikeButton.removeClass("unliked");
|
|
||||||
addLike("kommentar", thisComment.k_id, $(this))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
let kommentarErstellen = document.createElement("p");
|
let kommentarErstellen = document.createElement("p");
|
||||||
let kommentar = document.createTextNode(commentArray[i].k_text);
|
let kommentar = document.createTextNode(data[i].k_text);
|
||||||
kommentarErstellen.appendChild(kommentar);
|
kommentarErstellen.appendChild(kommentar);
|
||||||
kommentarErstellen.classList.add("comment");
|
kommentarErstellen.classList.add("loeschen");
|
||||||
document.getElementById('kommentare_container').appendChild(kommentarErstellen);
|
document.getElementById('kommentare_container').appendChild(kommentarErstellen);
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.log('Error!: ' + error.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+1
-23
@@ -7,39 +7,17 @@ require_once('data.php');
|
|||||||
$db = dbVerbindungErzeugen();
|
$db = dbVerbindungErzeugen();
|
||||||
|
|
||||||
$id = $_GET["id"];
|
$id = $_GET["id"];
|
||||||
$typ = $_GET["typ"];
|
|
||||||
|
|
||||||
if ($typ == "idee") {
|
|
||||||
$sql = "SELECT likes FROM idee WHERE id = $id";
|
$sql = "SELECT likes FROM idee WHERE id = $id";
|
||||||
$resultat = $db->query($sql);
|
$resultat = $db->query($sql);
|
||||||
$likeCount = $resultat ->fetchColumn();
|
$likeCount = $resultat ->fetchColumn();
|
||||||
$likeCount += 1;
|
$likeCount += 1;
|
||||||
|
|
||||||
|
|
||||||
|
echo ($likeCount);
|
||||||
|
|
||||||
$sql = "UPDATE idee SET likes=? WHERE id=?";
|
$sql = "UPDATE idee SET likes=? WHERE id=?";
|
||||||
$stmt = $db->prepare($sql);
|
$stmt = $db->prepare($sql);
|
||||||
$stmt->execute(array($likeCount, $id));
|
$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);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -23,7 +23,7 @@ $stmt->execute(array($titel, $inhalt, $lat, $lng));
|
|||||||
|
|
||||||
echo $db->lastInsertId();
|
echo $db->lastInsertId();
|
||||||
|
|
||||||
header("Location: /");
|
header("Location: https://751068-4.web.fhgr.ch/");
|
||||||
die();
|
die();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?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();
|
|
||||||
|
|
||||||
if ($likeCount > 0){
|
|
||||||
$likeCount -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
echo ($likeCount);
|
|
||||||
|
|
||||||
$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;
|
|
||||||
|
|
||||||
|
|
||||||
echo ($likeCount);
|
|
||||||
|
|
||||||
$sql = "UPDATE kommentar SET k_likes=? WHERE k_id=?";
|
|
||||||
$stmt = $db->prepare($sql);
|
|
||||||
$stmt->execute(array($likeCount, $id));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
Reference in new issue
Block a user