Help - Search - Members - Calendar
Full Version: Code to show Product Totals in Navigation.
CubeCart Forums > General > General Discussion
gnetsd
I've been asked a couple of time about how I show the amount of products per category in my cat_navi.php. Here are my modifications..

Here are my changes..

CODE
<?php
/***************************************************************************
*    File Info: cat_navi.php
*    Purpose:   Displays The Category Links Navigation
*    Updated:   31/07/2003
****************************************************************************  
*    Developer: Alistar Brookbanks (Brooky.com)
*    Copyright: (C)2003 http://www.brooky.com
*    Copyright: (C)2003 http://www.cubecart.com
*    This program is not "free" software and restrictions apply!
*    Further Info: http://www.cubecart.com/license.php
*    Contact support@cubecart.com if any conditions are not clear.
*
*    Licensees holding valid "CubeCart Licence Number" may edit
*    the (powered by CubeCart) from browser title and "Powered by CubeCart"
*    and "(c) Brooky.com" from the web page footer.
*
*    This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
*    THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
*    PURPOSE. This and all others in the download package can only be
*    redistributed with written permission from Alistair Brookbanks!
*
*    The "CubeCart License" is available to purchase at
*    https://secure.cubecart.com/
*    For pricing please contact us via e-mail at sales@cubecart.com
***************************************************************************/

$query = "SELECT * FROM ".$prefix."store_category where cat_father_id = 0 order by $cat_order";
$result = mysql_query($query);

$num_rows = mysql_num_rows($result);

// start border
sb("140","$la_cat_navi_category",$colour_1,$bg_colour);

// list Top-Level navigation
echo "<table border=\"0\" cellspacing=\"0\" width=\"100%\" cellpadding=\"2\" align=\"left\" bgcolor=\"#FFFFFF\">
<tr>
<td><img src='images/bullet.gif' border='0'>
</td>
<td align=\"left\"><a href='index.php'>$la_search_home</a></td>
</tr>";

while ($row = mysql_fetch_array($result))
{
$cat_id_list = $row["cat_id"];
$category = $row["category"];

$get_num_rows = "SELECT COUNT(cat_id) FROM ".$prefix."store_inventory WHERE cat_id = '$cat_id_list'";
$get_num_rows_rs = mysql_query($get_num_rows);
$numc_rows = mysql_result($get_num_rows_rs,0, 'count(cat_id)');

echo"<tr>
<td><img src='images/bullet.gif' border='0'></td><td align=\"left\"><a href='index.php?cat_id=$cat_id_list'>$category</a> <span class=\"num_rows\">($numc_rows)</span></td>
</tr>";
}

if($sale=="Y")
{
echo"<tr><td width='6'><img src='images/bullet.gif' border='0'></td><td align=\"left\"><a href='sale_cat.php'>$la_sale_items</a><td></tr>";
}
echo"</table>";
// end border

eb($bg_colour,$colour_1);
?>
<?php
mysql_free_result($result);
?>


The code for style.css
CODE
.num_rows {font-size: 8px; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif;
}


This had a small bug but I think I have fixed it..

Chris
gnetsd
As far as I can see, the bug in the above code has been fixed..

Let me know if you have a problem.
Chris
JOELENE
HI, THIS MOD LOOKED PRETTY GOOD TO ME, SO I TRIED IT, AND IT'S GREAT, BUT........WHY DOESN'T IT REGISTER WHAT IS IN THE SUBCATAGORIES? NOT MUCH GOOD IF IT SAYS THERE NOTHING IN THAT CATAGORY WHEN REALLY THERE ARE SEVERAL SUBFOLDERS WITH 100 THINGS IN EACH.
DON'T SUPPOSE YOU'VE HAD CHANCE TO UPDATE IT?
stuart.gif
iezhba@inktenzo.com
WOW!

YOUR CAPS ARE GETTING BIGGER EVERY TIME.


(super glue or coca cola spilled over your keyboard Joelene?)
JOELENE
SORRY!
There I turned them off.

biggrin.gif

Still don't get this mod though wacko.gif Anyone else managed to get it to tally the sub categories yet?
akumanz
yeah that'd be good if it could tally the sub cats. Then i'd be using it for sure biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.