Advertisement
Guest User

forum_home.php

a guest
Apr 19th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2.   $db = new mysqli('localhost', 'root', 'password', 'local');
  3.  
  4.   if ($db->connect_errno)
  5.   {
  6.   }
  7.   else
  8.   {
  9.     echo '<table>';
  10.     $req = $db->query('SELECT * FROM section');
  11.    
  12.     foreach ($req as $sec)
  13.     {
  14.       $req2 = $db->query('SELECT t.* FROM topics AS t WHERE t.id_section = ' . $sec['id']);
  15.  
  16.       // ligne de la section
  17.       echo '<tr class="section">';
  18.       echo '<td>' . $sec['name'] . '</td>';
  19.       echo '</tr>';
  20.  
  21.       foreach ($req2 as $top)
  22.       {
  23.         $req3 = $db->query('SELECT m.* FROM messages AS m, sujets AS s WHERE s.id_topic=' . $top['id'] . ' AND s.id=m.id_sujet ORDER BY m.post_date LIMIT 1');
  24.         if ($req3)
  25.           $msg = $req3->fetch_assoc();
  26.         else
  27.           $msg['content'] = "lol";
  28.  
  29.         echo '<tr class="topic">';
  30.         echo '<td>' . $top['name'] . '</td>';
  31.         echo '<td>' . $msg['content'] . '</td>';
  32.         echo '</tr>';
  33.       }
  34.     }
  35.  
  36.     echo '</table>';
  37.   }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement