Get information from database
$video_id = $_GET['id'];
$query = "SELECT * FROM video_comments WHERE video_id = :video_id";
$stmt = $pdo->prepare($query);
$stmt->bindValue(':video_id',$video_id);
$stmt->execute();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$id = $row['id']; // The id for each comment
// Show/Hide Script
echo '<script>function replyToCommentFunction'.$id.'() {
var x = document.getElementById("replyToComment'.$id.'");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}</script>';
<button name="replyToComment" class="videoCommentsReplyButton" onClick="replyToCommentFunction'.$id.'()">Reply</button>
// The Div to show...
echo '<div id="replyToComment'.$id291.'">';
echo 'Hello, World!';
echo '</div>';
}
I thought I had this working. But now, only one of the "reply" buttons work on the page. The most recent reply button refreshes the page, which confuses me, because no script or action exists, which would tell it to submit a form or refresh the page. I would appreciate any assistance. Thank You.