<?php
session_start();
$userid = $_SESSION['userid'];
?>
<?php
$z= $_POST["imgurl"];
$start = $_POST["start"];
$count = $_POST["count"];
$count2 = $count + 1;
$delete = "<i id='icon3' class='fa fa-times' aria-hidden='true' data-userid='$userid' data-commid='".$zeile['id']."'></i>";
try {
$db = new PDO('mysql:host=localhost;dbname=Datenbank_NEU', 'root', 'lehar456');
$sql = "SELECT kommentare.id ,kommentare.userid, kommentare.k_path, kommentare.eintrag, kommentare.autor, kommentare.datum, DATE_FORMAT(datum,'%d.%m.%Y um %H:%i') AS meindatum FROM `kommentare` WHERE kommentare.k_path = '$z' ORDER BY kommentare.datum DESC LIMIT $start, $count2";
$ergebnis = $db->query($sql);
$countread = 0;
foreach ($ergebnis as $zeile) {
if ($countread < $count) {
if ($userid == $zeile['userid']) {
printf("<p class='rest'><a class='Kom_name' href=\"mailto:%s\">%s</a> am %s $delete</p>
<h3>%s</h3><p style='margin-bottom: 15px;'>%s</p><hr noshade=\"noshade\" />",
urlencode($zeile['']), // da stand mal email
htmlspecialchars($zeile['autor']),
htmlspecialchars($zeile['meindatum']),
htmlspecialchars($zeile['']), // hier stand mal userid
nl2br(htmlspecialchars($zeile['eintrag']))
);
} else {printf("<p class='rest'><a class='Kom_name' href=\"mailto:%s\">%s</a> am %s</p>
<h3>%s</h3><p style='margin-bottom: 10px'>%s</p><hr noshade=\"noshade\" />",
urlencode($zeile['']), // da stand mal email
htmlspecialchars($zeile['autor']),
htmlspecialchars($zeile['meindatum']),
htmlspecialchars($zeile['']), // hier stand mal userid
nl2br(htmlspecialchars($zeile['eintrag']))
);}
}
$countread++;
}
if ($countread < $count2) {
echo '<span class="ende"></span>';
}
} catch (PDOException $e) {
echo 'Fehler: ' . htmlspecialchars($e->getMessage());
}
?>
<script>
$("#icon3").on("click", function {
var params = {
imgurl: imgurl, // weiss ich im Moment nicht, wo die her kommt, sollte aber verfügbar sein
userid: $(this).data("userid"),
commid: $(this).data("commid")
}
$.ajax({
url: "Kommentar_loeschen.php",
data: params,
type: "POST",
success: function(input) {
console.log("Success input = " + input); // kann später auch raus
$("#icon3").html(input);
},
error: function( /* Parameter entspr Doku */ ) {}
})
};
</script>