Jump to content

Forum


SieRobin

Recommended Posts

I'm creating a forum on my website.. all from scratch. Now I'm stuck on this part, I can't seem to figure it out, but perhaps you all could help me out with this. I want all the code in one page, because I don't want to use a million pages for the forum, so I'm using if/else statements in order to display the threads and board names. Here is the script I've written up.

[code]<?php
session_start();
include 'connect.php';
?>
<link rel="stylesheet" href="style.css" type="text/css">
<title>Feudal Age - Forum</title>
<?php
include "navigate.php";
if (isset($_SESSION['player']))
  {
  $player=$_SESSION['player'];
  $userstats="SELECT * from users where playername='$player'";
  $userstats2=mysql_query($userstats) or die("Could not retrieve the users stats.");
  $userstats3=mysql_fetch_array($userstats2);
  $brd=$_GET['brd'];
    if ($brd==) {  
         $thread="SELECT * from f_thread where bname='$brd' order by ID ASC";
          $thread2=mysql_query($thread) or die ("Could not display threads");  
        print "<table class='table'><tr class='headline'><td colspan='5'><center>Forum</center></td></tr>
        <tr class='headline'><td>Thread</td><td>Author</td><td>Last Poster</td><td>Replies</td><td>Views</td>";
        while ($thread3=mysql_fetch_array($thread2)) {
        print "<tr class='mainrow'><td><a href='forum.php?brd=1&msg=$thread3[ID]'>$thread3[title]</a></td>
        <td><a href='profile.php?id=$userstats3[ID]'>$thread3[author]</center></td><td>$thread3[lastpost]</td><td>$thread3[replies]</td>
        <td>$thread3[views]</td></tr>";
        }
        print "</table>";
        } else {
    $forum="SELECT * from f_forum order by ID ASC";
    $forum2=mysql_query($forum) or die("Could not retrieve the users stats.");
    print "<table class='table'><tr class='headline'><td colspan='4'><center>Forum</center></td></tr>
    <tr class='headline'><td>Board Name</td><td>Description</td></tr>";
    while ($forum3=mysql_fetch_array($forum2)) {
    print "<tr class='mainrow'><td><a href='forum.php?brd=$forum3[bname]'>$forum3[fname]</a></td><td>$forum3[desc]</td></tr>";
    }
    print "</table>";
    }
  }
?>[/code]

Ok, so this line..

[code]$brd=$_GET['brd'];
    if ($brd==) {  [/code]

I want to be able to like.. display that boards threads without having to put..

[code]if ($brd=="gen") {
do something }[/code]

I just want it to be able to know which board it's on and to show it's threads, anyone know how to do this? If you don't get what I'm saying I'll try and rephrase it.
Link to comment
https://forums.phpfreaks.com/topic/4283-forum/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.