Jump to content

O_O its only selected 1 row for each table O_O


Demonic

Recommended Posts

Well when I try and use this script its only selecting one forum for each category for some reason anysuggestions?

[code]
<?php

include("global_conf.php");


require_once('includes/template_engine.php');

?>
<!--board.php-->

<?php
/**
* Create user panel template
*/
  $TemplateEngine = new TemplateEngine;
  $TemplateEngine->TemplateDir = "styles/".$logged[skin]."/templates/";
  $TemplateEngine->SelectTemplateFile('userpanel', __LINE__, __FILE__);
  $TemplateEngine->ReplaceVars(array(
  'USER' => "Welcome <strong>".$logged[username]."</strong>!",//Username
  'CONTROLS' => "<?php require(\"sources/controls.php\"); ?>",//Username
), __LINE__, __FILE__);
$TemplateEngine->Compile();

/*
* Get the categories
*/

  $category = mysql_query("SELECT * FROM `category` WHERE `delete` = 'n' ORDER BY `order`")or die("There was an error loading the categories:<br />".mysql_error()."");
while($cat = mysql_fetch_array($category)){


/*
* Create the category template
*/

/* Create Forums from category*/
$showforums = mysql_query("SELECT * FROM `forums` WHERE cid='$cat[id]'") or die(mysql_error());
$showf = mysql_fetch_array($showforums);
//
if($showf){
$foruminfo = ('
<tr>
<td class="main" width="8%" align="center">{ICON}</td>
<td class="main" width="53%"><strong>'.$showf[forumname].'</strong><br /><font style="color: #999999;">{DESCRIPTION}</font></td>
<td class="main" width="9%" align="center">'.$showf[topics].'</td>
<td class="main" width="9%" align="center">'.$showf[replies].'</td>
<td class="main" width="20%">{LASTPOST}</td>
    </tr>
');
}else{
$foruminfo = "";
}

$TemplateEngine = new TemplateEngine;
  $TemplateEngine->TemplateDir = "styles/".$logged[skin]."/templates/";
  $TemplateEngine->SelectTemplateFile('category', __LINE__, __FILE__);
  $TemplateEngine->ReplaceVars(array(
  'CATEGORYNAME' => $cat[name],
  'FORUMS' => $foruminfo,
  'CATEGORYID' => $cat[id],
  ), __LINE__, __FILE__);

$TemplateEngine->Compile();

}

?>

<!--End Board.php-->
[/code]

if needed to look at heres the category.tpl file:

[code]
<table class="forumMain" cellpadding="2" cellspacing="1" width="100%" border="0">
<tr>
  <td colspan="5" class="head">{CATEGORYNAME}</td>
</tr>
<tr>
  <td class="subhead" width="61%" colspan="2">Forum</td>
  <td class="subhead" width="9%" align="center">Topics</td>
  <td class="subhead" width="9%" align="center">Replies</td>
  <td class="subhead" width="20%">LastPoster</td>
</tr>
{FORUMS}
<tr>
  <td style="border-bottom: 0px; background-color: #999999; height: 14px;" colspan="5"></td>
</tr>
</table>
[/code]
For categories you have a loop

[code]while($cat = mysql_fetch_array($category)){[/code]

But for forums you haven't included the loop.. you just have

[code]$showf = mysql_fetch_array($showforums);[/code]

This will cause you to only fetch one forum per category.  To fix it, make an inner loop for forums the same as the outer loop for categories.

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.