Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function replay_function ($conn){
- if (isset($_POST['replay-post'])) {
- if (empty($_POST['reply-content'])) {
- echo "you left put some fileds";
- }
- $message = mysqli_real_escape_string($conn,$_POST['reply-content']);
- $user_id = $_SESSION['id'];
- $topic_id = mysqli_real_escape_string($conn,$_GET['id']);
- $sql = "INSERT INTO replay_forum(replay,replay_date,replay_by,topic_replayed)
- VALUES('$message',NOW(),'$user_id','$topic_id')";
- $result = mysqli_query($conn,$sql);
- if(!$result)
- {
- //something went wrong, display the error
- echo 'something went wrong please try again later';
- }else {
- header('Location: ' .BASE_URL. '/topic?id='.$_GET["id"].' ');
- echo "<script>alert('your Replay Have been Saved successfully please refrech your page to see the changes')
- </script>";
- exit();
- }
- }
- }
- and thisis the code am using to display
- echo '<table border="1">
- <tr>
- <th>Category</th>
- <th>Last topic</th>
- </tr>';
- while($row = mysqli_fetch_assoc($result))
- {
- $cat_id = $row['cat_id'];
- echo '<tr>';
- echo '<td class="leftpart">';
- echo '<h3><a href="category.php?id='.$row['cat_id'].'">' . $row['cat_name'] . '</a></h3>
- <p class="p">' . $row['cat_description'];
- echo '</p></td>';
- echo '<td class="rightpart">';
- $topicsql = "SELECT topic_id,topic_subject,topic_date FROM topics WHERE
- topic_cat = '$cat_id' ORDER BY topic_date DESC LIMIT 0, 1
- ";
- $topicresult = mysqli_query($conn,$topicsql);
- if(!$topicresult)
- {
- echo 'nothing here yet';
- }else {
- if ($topicrow = mysqli_fetch_assoc($topicresult)) {
- echo '<a href="../forum/topic?id='.$topicrow['topic_id'].' ">
- '.$topicrow['topic_subject'].'</a> ';
- }
- }
- echo '</td>';
- echo '</tr>';
- }
- echo "</table>";
- }
- }
Add Comment
Please, Sign In to add comment