Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db = new mysqli('localhost', 'root', 'password', 'local');
- if ($db->connect_errno)
- {
- }
- else
- {
- echo '<table>';
- $req = $db->query('SELECT * FROM section');
- foreach ($req as $sec)
- {
- $req2 = $db->query('SELECT t.* FROM topics AS t WHERE t.id_section = ' . $sec['id']);
- // ligne de la section
- echo '<tr class="section">';
- echo '<td>' . $sec['name'] . '</td>';
- echo '</tr>';
- foreach ($req2 as $top)
- {
- $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');
- if ($req3)
- $msg = $req3->fetch_assoc();
- else
- $msg['content'] = "lol";
- echo '<tr class="topic">';
- echo '<td>' . $top['name'] . '</td>';
- echo '<td>' . $msg['content'] . '</td>';
- echo '</tr>';
- }
- }
- echo '</table>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement