Tag,
Ich möchte, dass beim betätigen des Button, die Seite nicht neu ladet.
kann mir jemand mal verraten was ich falsch mache?!
while($row = $stmt->fetch()) {
$sql4 ="
SELECT
comments.u_id,
comments.p_id,
u_post.u_id,
u_post.p_id
FROM comments
LEFT JOIN u_post
ON comments.p_id = u_post.p_id
WHERE comments.p_id = ?";
$new = $pdo->prepare($sql4);
$new->BindValue(1, $row['p_id']);
if(!$new->execute()) {
print_r($new->errorInfo());
}
$countss = $new->rowCount();
$row4 = $new->fetch();
echo '<div id="form-content">';
echo '<form method="POST" id="reg-form" autocomplete="off">';
echo '<br>Post-Id: '. $row['p_id'] . '<br>' . $row['post'] . '<br>';
echo 'Kommentare: ' . $countss . ' <br> ';
if($_POST['post-id'] === $row['p_id']) {
while($row2 = $result->fetch()) {
echo 'Kommentar: ' . $row2['comment'] .'<br>';
}
}
echo '<p><input type="submit" name="show" id="show"></p>';
echo '<p><input type="hidden" name="post-id" value="' . $row['p_id'] . '"></p>';
echo '_____________________';
echo '</form>';
echo '</div>';
}
?>
<script src="jQuery/jquery-3.3.1.min.js">
$("#show").click( function()
{
$.ajax({
url: "test.php",
type: 'POST',
success: function(result) {
//finished
}
});
});
</script>