View Single Post
Old February 17th, 2005, 08:23 PM   #13 (permalink)
Chuck S
Photopost Developer
Verified Customer
 
Chuck S's Avatar
 
Join Date: Jun 2002
Location: Abingdon,MD
Posts: 71,666
Replace your upgradecategories function in pp-inc.php with this one and run scan database recount posts

Quote:
function upgradecategories( $parent=0 ) {
global $Globals, $link;

// update categories
//
if ( $parent == 0 )
$query = "SELECT id,catname,description,catorder,parent,thumbs,children FROM {$Globals['pp_db_prefix']}categories ORDER BY catorder ASC";
else
$query = "SELECT id,catname,description,catorder,parent,thumbs,children FROM {$Globals['pp_db_prefix']}categories WHERE id=$parent ORDER BY catorder ASC";

$boards = ppmysql_query($query, $link);

while ( list( $id, $catname, $catdesc, $order, $catparent, $catthumbs, $children ) = mysql_fetch_row($boards) ) {
catlist( $id );

$lastposttime=""; $lastpostby=""; $lastpostlink="";
$lastphoid=""; $lastphoby=""; $lpholink="";
$newproducts=""; $laston=0;

if ( $children != "" ) $children = "$id,$children";
else $children = "$id";

$cproducts=0; $catposts=0;

$quid = "cat IN ($children)";

if ( $quid != "" && $quid != "cat=" ) {
// first we need to get last product/post info
$query = "SELECT id,user,userid,date FROM {$Globals['pp_db_prefix']}products WHERE $quid AND status=0 AND approved=1 ORDER BY date DESC";
$lastp = ppmysql_query($query, $link);

list( $lastphoid, $lastphoby, $lastphobyid, $lastphotime ) = mysql_fetch_row($lastp);
ppmysql_free_result($lastp);

//now we get the number of product, just in this category
$query = "SELECT id FROM {$Globals['pp_db_prefix']}products WHERE cat=$id AND status=0";
$lastp2 = ppmysql_query($query, $link);
$cproducts = mysql_num_rows($lastp2);
ppmysql_free_result($lastp2);

$query = "UPDATE {$Globals['pp_db_prefix']}categories SET lastproduct='$lastphoid', products='$cproducts' WHERE id=$id";
$resulta = ppmysql_query($query,$link);
}
}

return;
}
__________________
Photopost Developer and Support Engineer

Please do not PM me for support or sales questions. Thank you for your understanding.

Last edited by Chuck S; February 17th, 2005 at 09:34 PM.
Chuck S is online now   Reply With Quote