Hi all, its a bit hard to explain what i’m trying to do in one sentance. I’m trying to create a forum index menu using a sql query and joining some data up.
I have managed to get it to list all the forum halls that are shown as being online, but inside each forum hall there are sub-forums. Now this is where i am currently having a problem. I can get it to show the first sub-forum in each hall, but no more. now i have several sub-forums in my first forum hall (noting else in the other halls yet).
so you know what i have done its easier for me to show you the whole page of code (ignore the include files they aren’t important), what is important is the SQL query and the code that follows it.
<?php
/******************************************/
/* Content Management System */
/* ©2010 Tdf Enterprises */
/* */
/* Dynamically Sourced Forum Index File */
/* */
/* Please Leave This Notice Intact */
/* As Part Of The Copyright - ©Tdf 2010 */
/******************************************/
session_start();
// gather required file: auth-user
require 'authentication/users.php';
// set the page name
$pageTitle = 'The Forum Halls';
// gather required files: header.inc, sidebar.inc
require 'includes/header.inc.php';
require 'includes/sidebar.inc.php';
?>
<!--
/******************************************/
/* Content Management System */
/* ©2010 Tdf Enterprises */
/* */
/* The Dynamic Forum Index File */
/* */
/* Please Leave This Notice Intact */
/* As Part Of The Copyright - ©Tdf 2010 */
/******************************************/
-->
<?php
// gather forum hall info
$sql = <<<EOS
SELECT h.hall_id as id, h.hall_name as fhall,
h.hall_description as description,
u.name as admin, s.subforum_id as subid,
s.subforum_name as subname, s.subforum_desc as subdesc,
s.subforum_moderator as submod
FROM cms_forum_halls h
LEFT JOIN cms_hall_subforums s
ON h.hall_id = s.hall_id
LEFT JOIN cms_user_info u
ON h.hall_administrator = u.id
WHERE hall_status = 1
GROUP BY h.hall_id
EOS;
$result = mysql_query($sql, $conn)
or die ('Could not retrieve indexable information for the forum halls: ' .mysql_error());
if (mysql_num_rows($result) == 0) { ?>
<div class="feature"> <img src="images/defaults/RCLamenColour.gif" height="200" width="200" />
<h3>Forums Notification</h3>
<p> It appears the forums are currently offline.<br>
This may be a temporary issue that the administrators are working on.<br>
Please check back later!.
</div>
<?php } else {
while ($row = mysql_fetch_array($result)) {
?>
<div class="story">
<ul class="accordion">
<li id="<?php echo $row['id'];?>">
<h2><a href="#<?php echo $row['id'];?>"><?php echo $row['fhall'];?></a></h2>
<p><?php echo $row['description'];?></p>
<p>Hall Administrator: <?php echo $row['admin'];?></p>
<div class="links">
<h3>Sub-Forums</h3>
<ul>
<li><a href="viewforum.php?hall=<?php echo $row['id'];?>&subforum=<?php echo $row['subid'];?>"><?php echo $row['subname']?></a><br><?php echo $row['subdesc'];?></li>
</ul>
</div>
</li>
</ul>
</div>
<?php
}
}
// gather required file: footer.inc
require 'includes/footer.inc.php';
?>
now as you can see its this piece of code that i need help with:
<?php
// gather forum hall info
$sql = <<<EOS
SELECT h.hall_id as id, h.hall_name as fhall,
h.hall_description as description,
u.name as admin, s.subforum_id as subid,
s.subforum_name as subname, s.subforum_desc as subdesc,
s.subforum_moderator as submod
FROM cms_forum_halls h
LEFT JOIN cms_hall_subforums s
ON h.hall_id = s.hall_id
LEFT JOIN cms_user_info u
ON h.hall_administrator = u.id
WHERE hall_status = 1
GROUP BY h.hall_id
EOS;
$result = mysql_query($sql, $conn)
or die ('Could not retrieve indexable information for the forum halls: ' .mysql_error());
if (mysql_num_rows($result) == 0) { ?>
<div class="feature"> <img src="images/defaults/RCLamenColour.gif" height="200" width="200" />
<h3>Forums Notification</h3>
<p> It appears the forums are currently offline.<br>
This may be a temporary issue that the administrators are working on.<br>
Please check back later!.
</div>
<?php } else {
while ($row = mysql_fetch_array($result)) {
?>
<div class="story">
<ul class="accordion">
<li id="<?php echo $row['id'];?>">
<h2><a href="#<?php echo $row['id'];?>"><?php echo $row['fhall'];?></a></h2>
<p><?php echo $row['description'];?></p>
<p>Hall Administrator: <?php echo $row['admin'];?></p>
<div class="links">
<h3>Sub-Forums</h3>
<ul>
<li><a href="viewforum.php?hall=<?php echo $row['id'];?>&subforum=<?php echo $row['subid'];?>"><?php echo $row['subname']?></a><br><?php echo $row['subdesc'];?></li>
</ul>
</div>
</li>
</ul>
</div>
<?php
}
}
And specifically, its this piece of code that i wish to be looping through however many sub-forums i have in each hall:
<li><a href="viewforum.php?hall=<?php echo $row['id'];?>&subforum=<?php echo $row['subid'];?>"><?php echo $row['subname']?></a><br><?php echo $row['subdesc'];?></li>
I appreciate any help that you can give me to solving this puzzle and thank you all in advance.