Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="content">
- <?php
- include"includes/connect.php";
- $select_posts="select* from posts ";
- $run_posts=mysqli_query($con, $select_posts);
- while($row=mysqli_fetch_array($run_posts)){
- $post_id=$row['post_id'];
- $post_title=$row['post_title'];
- $post_date=$row['post_date'];
- $post_author=$row['post_author'];
- $post_image=$row['post_image'];
- $post_keywords=$row['post_keywords'];
- $post_content=$row['post_content'];
- ?>
- <h2> <?php echo $post_title; ?></h2>
- <p align="left" > Published on: <b><?php echo $post_date; ?></b></p>
- <p align="right" > Posted by: <b><?php echo $post_author; ?></b></p>
- <center><img src="images/<?php echo $post_image; ?>" width="500" height="300"/></center>
- <p align="right"> <a href="">Read More</a></p>
- <?php
- echo "<form method = 'POST' action='content.php'>
- <input type='hidden' name='user_id' value='anonymous'>
- <input type='hidden' name='date' value='".date('Y-m-d H:i:s')."'>
- <textarea name='message'></textarea>
- <br>
- <button type ='submit' name ='commentSubmit'>comment</button>
- </form>";
- if(isset($_POST['commentSubmit'])){
- $uid=$_POST['user_id'];
- $date=$_POST['date'];
- $message=$_POST['message'];
- $insert_comment="INSERT INTO comment(user_id, date,message) values('$uid','$date','$message')";
- $run_comment=mysqli_query($con,$insert_comment);
- // fetch data from the database
- }
- ?>
- <?php
- $query = "SELECT * FROM comment, posts WHERE comment_id=$post_id";
- if ($result= mysqli_query($con, $query)){
- while($row=mysqli_fetch_assoc($result)){
- echo "<div class='comment-box'>";
- echo $row ['user_id']."<br>";
- echo $row ['date']."<br><br>";
- echo nl2br ($row ['message']);
- echo"</div>";
- }
- mysqli_free_result($result);
- }
- ?>
- <p align="justify" > <b><?php echo $post_content; ?></b></p>
- <?php }?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment