php – display recent replied thread post on top-ThrowExceptions

Exception or error:

but how would I go about showing the thread that has the most recent reply

example

- This is a thread 1
- This is a thread 2
- This is a thread 3

to

- This is a thread 3 with a new reply
- This is a thread 1
- This is a thread 2

This is the reply code if thats any help:

<?php 
                   $bro = $_GET['id'];
      $results_per_page = 5;
      $tablo = $trow['TTABLE'];
      $stmt = $db->query("SELECT COUNT(ID) AS total FROM $tablo");
      $page = $stmt->fetch();
      $total_pages = ceil($page["total"] / $results_per_page);
      ?> Pages: <?php for ($i=1; $i<=$total_pages; $i++) {  // print links for all pages
           echo "<a href='viewthread?page=".$i."&id=$bro'";
            if ($i==$page)  echo " class='curPage'";
            echo ">   ".$i."</a> "; 
}; 
                     if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }

                         </td>
                         </tr>
                         </table>
                         <br/> <br/>
                         <?php } ?>
                          <form id ="reply" action=''enctype="multipart/form-data"  method ="post">
                    <!--  <input type="text" class="disabled" value ="<?php //echo $prowx['MESSAGE'];?>  ">
                      <input type="text" class="hidden" value ="<?php// echo $prowx['NAME']; ?> "> -->
                     <div class="form-group">

                      <textarea id="editorx" name="message"></textarea>
                <script>
                        ClassicEditor
                                .create( document.querySelector( '#editorx' ) )
                                .then( editor => {
                                        console.log( editor );
                                } )
                                .catch( error => {
                                        console.error( error );
                                } );
                </script>
                    </div>

                      <div class="form-group">


 <input type="file" name="photo"  class="btn btn-light mr-2" placeholder="UPLOAD">       
 <button class="btn btn-light">Cancel</button>  <button type="submit" name="submit" class="btn btn-primary mr-2">REPLY THREAD</button>
                  </form>

this is index code where threads will show


<div id="Contact" class="tabcontent" style="border-bottom:2px solid white;">         
                    <?php
$stmt = $db->query('SELECT ID,PNAME,PDESC,STAGE FROM THREADS ORDER BY UPDATES DESC, ID DESC LIMIT 10');
while($trow2 = $stmt->fetch()){
    echo '<br/>';

here UPDATES column refers to when thread was created on
here pname is name of the thread and pdesc is description for threads
and the stage is to monitor the threads and i limited threads by 10 and i don’t understanding how to display newly replied thread show on top , i manage to display newly created threads on top

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *