Basically if the user want to comment on the product,it needs to show the last comments on that product.
Here is the Comment.php code and here the data of comments inserting in to the database but the problem is i want to display the previous comments of the product on the same page after the comment box.
Any suggestions?
<?php
include('GenericClasses/GenericCollectionClass.php');
include('Models/UsersModel.php');
include('DataObjects/Users.php');
//If you are not submitting the form HTML will be directly shown
if (!isset($_POST['submit']))
{
?>
<html>
<head>
<link href="facebox.css" media="screen" rel="stylesheet" type="text/css" />
<link href="CSS/screen.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form action="" method="post" name="postsForm">
<div class="UIComposer_Box">
<span class="w">
<textarea class="input" id="watermark" name="watermark" style="height:50px" cols="50" ></textarea>
</span>
</div>
<div align="left" style="height:30px; padding:10px 5px;">
<input type="submit" name="submit" style="background-color: orange;" value="postComment">
</div>
<?php
}
else
{
//If you are submitting the form insert the details into database
$Comments = $_POST['watermark'];
if (!(empty($Comments)))
{
$model = new UsersModel();
$rowsCount = $model->InsertComments($Comments);
}
if ($rowsCount!=0)
{
echo'Inserted';
} else{
echo 'Not Inserted';
}
}
?>
</form>
</body>
</html>
Use any of the below query.
SELECT row
FROM table
WHERE id=(
SELECT max(id) FROM table
)
Note that if the value of max(id) is not unique, multiple rows are returned. Or try this one
SELECT row from table ORDER BY id DESC LIMIT 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.