What's new

No display

loktoy

Eternal Poster
Joined
Oct 20, 2014
Posts
1,166
Solutions
2
Reaction
103
Points
496
Age
30
no display o output kapag nag iinput ako pero pumapasok sya sa database ..


<div class="container col-md-6 bg-body-tertiary border mt-3 rounded-3" >
<form method="POST">
<input type="hidden" name="id" value="<?php echo $username; ?>">
<label class="fw-bold mb-2" for="w3review">Comment:</label>
<textarea name="comment_content" class="form-control" rows="4" cols="40" placeholder="Your Content....."></textarea>
<div class="form-group mb-2 mt-2" style="text-align: right">
<input type="submit" name="comment" value="Reply" class="w-25" style="background-color:#0D52C7;">
</div>
</form>
</div>


<?php

if (isset($_POST['comment'])){
$comment_content = $_POST['comment_content'];
$post_id=$_POST['id'];

mysqli_query($con,"INSERT INTO comment (comment,date_posted,user_id,comment_id) VALUES('$comment_content','".strtotime(date("Y-m-d h:i:sa"))."','$user_id','$post_id')") or die (mysqli_error());

}
?>

<?php
$comment_query = mysqli_query($con,"SELECT * FROM comment LEFT JOIN registration on registration.user_id = comment.user_id WHERE comment_id = '$id'") or die (mysqli_error());
while($comment_row = mysqli_fetch_array($comment_query)){
$comment_id = $comment_row['comment_id'];
$comment_by = $comment_row['username'];
?>

<div class="container col-md-6 bg-body-tertiary border rounded-3" >
<a style="text-decoration:none; float:left;" href="deletepost.php<?php echo '?id='.$id; ?>">
<div class="pt-3">

<h5>Posted by: <a href="#" style= "margin-left:10px; text-decoration:none;"> <?php echo $comment_by; ?></a></h5>
<h6><?php echo $comment_row['username']; ?></h6>

<h5><?php echo $comment_row['comment']; }}?></h5>
 
Based on the code you provided, it seems that you are successfully inserting the input data into the database, but you are not seeing any output on the display. There could be several reasons for this issue. Here are a few things you can check:

1. Make sure you have the appropriate PHP tags (<?php ?>) around the code blocks. It looks like the code is already enclosed in PHP tags, but double-check to ensure they are properly placed.

2. Verify that the $username variable is properly set before the hidden input field. If $username is not set or has an empty value, it may cause issues when inserting into the database.

3. Check if the $id variable is properly set before the comment query. If $id is not set or has an empty value, it may cause the query to fail or return no results.

4. Make sure you have the necessary database connection code ($con) before executing any database queries. If the connection is not established properly, the queries will fail.

5. Check if there are any error messages being returned by the database functions. You can use mysqli_error($con) to display any errors that occur during the query execution. This can help identify any issues with the database queries.

6. Verify that the database table structure and column names match the ones used in your code. Any discrepancies can cause the queries to fail.

By checking these points and troubleshooting any potential issues, you should be able to identify the reason for the missing output on the display.
 

Similar threads

Back
Top