Hello, Im making a php site and currently have one comment section that has like buttons and thus ranks comments in order of date and likes. However I want to have four different comment sections for different topics like how this forum works. I have a table in my phpadmin database that has sentiment and date, for my idea to work will i need another row perhaps called category to select comments from a certain category and apply these thanks.
below is the code which deals with user ids and date/time stamps.
$comment = clean_string($db_server, $_POST['comment']);
if($comment != ""){
$query = "INSERT INTO comments (userID, comment) VALUES (" . $_SESSION['userID'] . ", '$comment')";
mysqli_query($db_server, $query) or
die("Insert failed: " . mysqli_error($db_server) );
$str_message = "Thanks for your comment!";
}
//Create comments with or without submission
$query = "SELECT comments.commDate, comments.ID, comments.userID,
comments.comment, comments.sentiment, users.username FROM comments JOIN users ON
comments.userID = users.ID ORDER BY sentiment DESC";
$result = mysqli_query($db_server, $query);
if (!$result) die("Database access failed: " . mysqli_error($db_server) );
while($row = mysqli_fetch_array($result)){
$str_comments .= "<p><em>" . $row['username'] . ": (" . $row['commDate'] . ")</em><br /> " .$row['comment'] ." (" . $row['sentiment'] . ") ";
if(!isset($_SESSION["liked_" . $row['ID']])){
$str_comments.= "<a href=\\"likeprocess.php?likeid=" . $row['ID'] . "\\"> This is a good present </a></p><hr />";
}else{
$str_comments .= "liked<hr />";
}
of course below this i have echo results and message, i haven’t included them as they are not the problem.
Once again, thanks