Jump to content

Questions for same code


Mekaboo

Recommended Posts

Hey ☺️

1. Form works but as far as output its image not text(comment). The echo I have in place seems not to work. Goal is to have users add an image and if they want give a description to the image all together...like a social media post.

2. Also like a social media site would like add a comment/reply section. When I try to attach it doesn't work. Could I use a simple form with a text area and echo..if so how do I attach it to the card so it will work?

3. With the loop the comment responses repeat themselves. How do I edit the loop so that a user can add a different comment(whether is solo or attached to pic) each time?

 

Here is my code:

```

  <form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload">
 <label>Upload Image File:</label><br/>
<input name="userImage" type="file" class="inputFile" />
   <label>Words:</label><br/>      
 <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>
  <br><br>
   <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>       
  <input type="submit" value="Submit" name="submit">
</form>
      </div>
    </div>
  </div>
</div>
 
   <br>
  <br>
  <br>
  <br>
<div class="row row-cols-1 row-cols-md-2 g-4">
<?php
 require_once "db.php";
    $sql = "SELECT imageId FROM output_images ORDER BY imageId DESC";
    $result = mysqli_query($conn, $sql);

//  Loop thru comments and display all of them
while($row = mysqli_fetch_array($result)) {
    printf("%s (%s)\n", $row["username"], $row["comment"],$row["imageId"]);
?>
  <div class="row">
        <a href="pro.php">
            <div class="alert alert-secondary" role="alert">
               <h5 class="card-content"><?php echo $username;?> </h5>
               <p class="alert-content"><?php echo $comment;?> </p>
            </div>
          </div>
  </div>
  </div>
     
            <div class="row">
        <a href="pro.php">
            <div class="card">
               <h5 class="card-content"><?php echo $username;?> </h5>
              <p class="alert-content"><?php echo $comment;?> </p>
                     <img src="imageView.php?image_id=<?php echo $row["imageId"]; ?>" class="card-img-top" alt="...">
            </div>
        </a>
    </div>

```

 

Thank ya❤️

Edited by Mekaboo
Add words/code
Link to comment
Share on other sites

  • Mekaboo changed the title to Questions for same code

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...