CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Tree Form Count Items in CC2

Print topic Send  topic

Author Message
Steven
Posted: 10/09/2002, 3:36 AM

This question refers to CodeCharge 2 , with php4+Mysql.

Can anyone help me modify the tree form so that it shows a count() of the
items in the directories as part of the actual tree menu?

I have a std db'+ Classifieds based tree form, in php4+mysql db, I have grabbed
the produced code below to show that all is basically std, but itisnt set to
use custom code in the project.

In my Project this tree form is linked in CC to an "ads_categories" mysql
table, my classifieds are in an "ads_listings" table

How do i introduce a mysql count for how many I would think i need something
like this

"select count(*) from ads_listings where ad_id=$category_id" ?

Thanks

Steven



//-------------------------------
?>
<table >
<tr>
<td bgcolor="#F99E39" align="center">
<font face="arial" color="#000000" style="font-weight:
bold"><?=$sFormTitle?></font>
</td>
</tr>
<tr>
<td bgcolor="#FFBB77">
<nobr><font face="arial" size="2" style="font-weight: bold">
<a href="<?= $action_page ?>?FormName=Tree">
<font face="arial" size="2" style="font-weight: bold">Top</font></a>
<?

$sSQL = "select category_id, category_name, category_id_parent from
ads_categories";
$sCatID = get_param("category_id");

if(!strlen($sCatID) || !is_number($sCatID))
{
//-------------------------------
// Root category
//-------------------------------
$sWhere = " WHERE category_id_parent IS NULL OR category_id_parent=0";
}
else
{
//-------------------------------
// Subcategory
//-------------------------------
$sWhere = " where category_id=" . $sCatID;
$db->query($sSQL . $sWhere);
$db->next_record();
$current_category = tohtml($db->f("category_name"));
$sParCatID = tohtml($db->f("category_id_parent"));
//-------------------------------
// Build Path
//-------------------------------
$sPath = "";
while($sParCatID != "")
{
$db->query($sSQL . " where category_id=" . $sParCatID);
if($db->next_record())
{
$category_name = tohtml($db->f("category_name"));
$category_id = tohtml($db->f("category_id"));

$sParCatID = tohtml($db->f("category_id_parent"));
$sPath="<a
href=\"$action_page?FormName=Tree&category_id=$category_id\">
<font " . "face=\"arial\" size=\"2\"
style=\"font-weight: bold\"" . ">" . $category_name . "</font></a> > " .
$sPath;
}
else
break;
}
echo " > ".$sPath;
echo $current_category;
$sWhere = " where category_id_parent=" . $sCatID;
}
?>
</font></nobr>
</td>
</tr>
<?
//-------------------------------
// Categories list
//-------------------------------
$db->query($sSQL . $sWhere);
if($db->next_record())
{
//-------------------------------
// Print subcategories
//-------------------------------
do
{
$category_id = tohtml($db->f("category_id"));
$category_name = tohtml($db->f("category_name"));
?>
<tr>
<td bgcolor="#FFFFFF">
<a href="<?= $action_page ?>?FormName=Tree&category_id=<?=
$category_id ?>"><font face="arial" size="2"><?= $category_name
?></font></a></td></tr>
<?
} while ($db->next_record());
}
//-------------------------------
echo "</table>";
//-------------------------------

desdon
Posted: 10/09/2002, 3:48 PM

I have attemped similar, ended up having to add a column to the grid because I coudn't get it to work on a tree form

has anyone managed to count items from the tree


dres

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.