sabret00the
02-07-2005, 02:34 PM
// ###################### groups by cat
$grps_categories = $DB_site->query("
SELECT grps.groupid, grps.title, grps.description,grps.catid, grps_catergories.title AS catname, grps.approved,grps.leaderid
FROM grps
LEFT JOIN grps_catergories ON(grps_catergories.catid = grps.catid)
WHERE grps.approved=1
ORDER BY grps_catergories.catid ASC, grps.title ASC
");
if (!$DB_site->num_rows($grps_categories))
{ // nogroups, this becomes obselete after the first group gets created
eval("\$grps_catbits = \"" . fetch_template("groups_browse_cathead") ."\";");
$grps_catbits .="<tr><td class=\"alt1\" align=\"center\">no groups found inthis catergory at this time</td></tr>";
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_catfoot") ."\";");
}
else
{ // display the information
$row = "0";
while ($grps_categoryinfo =$DB_site->fetch_array($grps_categories))
{
if ($row == 0)
{
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_cathead") ."\";");
// resetcatname store
$grps_catidstore = $grps_categoryinfo['catid'];
}
echo"$grps_categoryinfo[catid]<br />";
if ($grps_catidstore !=$grps_categoryinfo[catid] AND $row != 0)
{
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_cathead") ."\";");
// resetcatname store
$grps_catidstore = $grps_categoryinfo['catid'];
}
$grps_categoryinfo['title'] =stripslashes($grps_categoryinfo['title']);
$grps_categoryinfo['description']= nl2br(stripslashes($grps_categoryinfo['description']));
$grps_categoryinfo['catname'] =stripslashes($grps_categoryinfo['catname']);
extract($grps_categoryinfo);
eval("\$grps_catbits .= \"" .fetch_template("groups_browse_catbit") . "\";");
if ($grps_categoryinfo[catid] !=$grps_catidstore)
{
// can't getinto this for some reason
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_catfoot") ."\";");
}
// else
// {
// eval("\$grps_catbits .= \"" . fetch_template("groups_browse_catfoot") ."\";");
// }
$row++;
} //now echo the date into the template
}
the code above is actually perfect, well it works anyway, only problemis that it doesn't actually seem to work, i can't get into theconditonal that groups the data together rather than it just creating anew table, wondered if anyone could help please, as i havne't got aclue what's wrong with it, especially as echoing out the data manuallyshows that it should be doing what i'm trying to do.
basically $grps_catidstore echo's out 4
4
4
8
8
and $grps_catergoryinfo = 4
4
4
4
8
now based on that the first three should be in one table (it'sextracting one groups_browse_cathead and one groups_browse_catfoot) butfor some reason it won't do it :(
$grps_categories = $DB_site->query("
SELECT grps.groupid, grps.title, grps.description,grps.catid, grps_catergories.title AS catname, grps.approved,grps.leaderid
FROM grps
LEFT JOIN grps_catergories ON(grps_catergories.catid = grps.catid)
WHERE grps.approved=1
ORDER BY grps_catergories.catid ASC, grps.title ASC
");
if (!$DB_site->num_rows($grps_categories))
{ // nogroups, this becomes obselete after the first group gets created
eval("\$grps_catbits = \"" . fetch_template("groups_browse_cathead") ."\";");
$grps_catbits .="<tr><td class=\"alt1\" align=\"center\">no groups found inthis catergory at this time</td></tr>";
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_catfoot") ."\";");
}
else
{ // display the information
$row = "0";
while ($grps_categoryinfo =$DB_site->fetch_array($grps_categories))
{
if ($row == 0)
{
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_cathead") ."\";");
// resetcatname store
$grps_catidstore = $grps_categoryinfo['catid'];
}
echo"$grps_categoryinfo[catid]<br />";
if ($grps_catidstore !=$grps_categoryinfo[catid] AND $row != 0)
{
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_cathead") ."\";");
// resetcatname store
$grps_catidstore = $grps_categoryinfo['catid'];
}
$grps_categoryinfo['title'] =stripslashes($grps_categoryinfo['title']);
$grps_categoryinfo['description']= nl2br(stripslashes($grps_categoryinfo['description']));
$grps_categoryinfo['catname'] =stripslashes($grps_categoryinfo['catname']);
extract($grps_categoryinfo);
eval("\$grps_catbits .= \"" .fetch_template("groups_browse_catbit") . "\";");
if ($grps_categoryinfo[catid] !=$grps_catidstore)
{
// can't getinto this for some reason
eval("\$grps_catbits .= \"" . fetch_template("groups_browse_catfoot") ."\";");
}
// else
// {
// eval("\$grps_catbits .= \"" . fetch_template("groups_browse_catfoot") ."\";");
// }
$row++;
} //now echo the date into the template
}
the code above is actually perfect, well it works anyway, only problemis that it doesn't actually seem to work, i can't get into theconditonal that groups the data together rather than it just creating anew table, wondered if anyone could help please, as i havne't got aclue what's wrong with it, especially as echoing out the data manuallyshows that it should be doing what i'm trying to do.
basically $grps_catidstore echo's out 4
4
4
8
8
and $grps_catergoryinfo = 4
4
4
4
8
now based on that the first three should be in one table (it'sextracting one groups_browse_cathead and one groups_browse_catfoot) butfor some reason it won't do it :(