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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.