View Full Version : Forum problem

03-09-2009, 09:53 PM
Hello im trying to make a forum, for the front page im trying to make it display a catergory with its forums.

here is my code

require './connect.php';

die('Could not connect: ' . mysql_error());

session_start(); // Starts the session.
if ($_SESSION['logged'] != 1) { // There was no session found!
header("Location: login.php"); // Goes to login page.
exit(); // Stops the rest of the script.
mysql_connect("$dbhost", "$dbuser", "$dbpass")or die("cannot connect");
mysql_select_db("$dbname")or die("cannot select DB");

$sql2="SELECT * FROM $tbl_name2";
$sql3="SELECT * FROM $tbl_name WHERE forum_type='1'";
// OREDER BY id DESC is order result by descending

<p align="center"><? echo $rows2['forumname']; ?></p>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong><?php echo $rows3['forum_name']; ?></strong></td>

$sql="SELECT * FROM $tbl_name WHERE forum_type='0' AND parent_id='$parent_id' ORDER BY id DESC";
while($rows=mysql_fetch_array($result)){ // Start looping table row
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><a href="view_forum.php?id=<? echo $rows['id']; ?>"><? echo $rows['forum_name']; ?></a><BR></td>


All it does is at the moment is display one of the catergory's with its child forums but not the second.

Here is my MYSQL structure.

Table structure for table forums
Field Type Null Default
id int(4) No
parent_id int(4) No 0
forum_name varchar(32) No
forum_type tinyint(4) No 0

1 3 Test 0
2 0 Test Catergory 1
3 0 Test cat 2 1
7 2 Forum1 0

forum_type 1 = Catergory
forum_type 0 = Forum

Any help would be great.

03-11-2009, 06:24 PM
anyone have any solutions?