Guest User

Untitled

a guest
Jan 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. function replay_function ($conn){
  2. if (isset($_POST['replay-post'])) {
  3. if (empty($_POST['reply-content'])) {
  4. echo "you left put some fileds";
  5. }
  6. $message = mysqli_real_escape_string($conn,$_POST['reply-content']);
  7. $user_id = $_SESSION['id'];
  8. $topic_id = mysqli_real_escape_string($conn,$_GET['id']);
  9. $sql = "INSERT INTO replay_forum(replay,replay_date,replay_by,topic_replayed)
  10. VALUES('$message',NOW(),'$user_id','$topic_id')";
  11. $result = mysqli_query($conn,$sql);
  12. if(!$result)
  13. {
  14. //something went wrong, display the error
  15. echo 'something went wrong please try again later';
  16. }else {
  17. header('Location: ' .BASE_URL. '/topic?id='.$_GET["id"].' ');
  18. echo "<script>alert('your Replay Have been Saved successfully please refrech your page to see the changes')
  19. </script>";
  20. exit();
  21. }
  22. }
  23. }
  24. and thisis the code am using to display
  25.  
  26. echo '<table border="1">
  27. <tr>
  28. <th>Category</th>
  29. <th>Last topic</th>
  30. </tr>';
  31.  
  32. while($row = mysqli_fetch_assoc($result))
  33. {
  34. $cat_id = $row['cat_id'];
  35. echo '<tr>';
  36. echo '<td class="leftpart">';
  37. echo '<h3><a href="category.php?id='.$row['cat_id'].'">' . $row['cat_name'] . '</a></h3>
  38. <p class="p">' . $row['cat_description'];
  39. echo '</p></td>';
  40. echo '<td class="rightpart">';
  41. $topicsql = "SELECT topic_id,topic_subject,topic_date FROM topics WHERE
  42. topic_cat = '$cat_id' ORDER BY topic_date DESC LIMIT 0, 1
  43. ";
  44. $topicresult = mysqli_query($conn,$topicsql);
  45. if(!$topicresult)
  46. {
  47. echo 'nothing here yet';
  48. }else {
  49. if ($topicrow = mysqli_fetch_assoc($topicresult)) {
  50. echo '<a href="../forum/topic?id='.$topicrow['topic_id'].' ">
  51. '.$topicrow['topic_subject'].'</a> ';
  52. }
  53. }
  54. echo '</td>';
  55. echo '</tr>';
  56. }
  57. echo "</table>";
  58. }
  59. }
Add Comment
Please, Sign In to add comment