I am trying to display images from my directory but unable to fetch the image using ID

okay so i took out the primary as well and it works fine now thank you sir.

Sir this is what i did but it only shows single comment but not the other comments with the same id’s? please help me again!

<?php
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$conn = mysqli_connect("localhost","root", "","registration");

if (!isset($_GET['id']) || trim($_GET['id'])=='') {
    header("Location: ");
    exit;
}

$res = $conn->prepare("SELECT id
                            , comment
                            FROM comments
                       WHERE id = ?
                       ");
$res->bind_param('i', $_GET['id']);
$res->execute();
$res->bind_result($id,$comment);
$res->fetch();
$res->close();
?>
<div>
            <b>Comments :</b>
            <div class="data"><?php echo $comment ?></div>
        </div>

No, you need two IDs in the table:

commentid   auto-inc unique  the ID of each individual comment
propid                       the ID of the proposal that the comment refers to 
text                         the comment text

Well, you only retrieve a single row, so it will only show a single comment. You need to have your fetch() inside a loop:

while ($res->fetch()) { 
  echo $comment;
  }

to retrieve more than one row from your query.

1 Like

okay got it sir thanks alot :slight_smile:

Sir i have a question incase i want to send a mail from localhost to gmail or other mail apps after the user submits its new proposal how would that be?

There are plenty of topics on this board showing how to send mail from PHP. Do a search for “PHPMailer” and you’ll find some - that’s the library generally suggested as being more reliable than the PHP in-build mail() function.

If you have any trouble implementing it, I’d suggest you open a new thread rather than adding to this one.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.