function build_ad_count($cat) { //include ("../include/posts.inc.php"); // get number of posts for this category $sql = search_category_for_ads($cat); $sql = "SELECT * FROM ads WHERE 1=1 {$sql} "; $result = mysql_query($sql) or die(mysql_error() . $sql); $count = mysql_num_rows($result); $c_row = get_category($cat); //echo "".$c_row['category_name']." --> $count<br>"; // are there more cats? $sql = "SELECT * FROM categories WHERE parent_category_id='{$cat}' "; $result = mysql_query($sql) or die(mysql_error() . $sql); while ($row = mysql_fetch_array($result)) { $count = $count + build_ad_count($row['category_id']); } $sql = "UPDATE categories SET obj_count='{$count}' WHERE category_id='{$cat}' AND form_id=3 "; mysql_query($sql) or die(mysql_error() . $sql); return $count; }
<input type="hidden" name="action" value="edit"> <input type="submit" value="Save"> </td> </tr> </table> </form> <hr> <p> </p> <?php } //if ($new_cat == '') { $MODE = "ADMIN"; showAllCat($_REQUEST['cat'], 1, 3, $_SESSION['MDS_LANG'], $_SESSION[form_id]); if ($_SESSION[form_id] == 1) { require_once '../include/ads.inc.php'; build_ad_count($_REQUEST['cat']); // echo "cats rebuilt."; } //} ?> </table> <?php ?> </div> </body> </html>