PDA

Просмотр полной версии : отключить подсчет колличества обьявлений [PHP file]


ufalog
12.08.2009, 12:10
как?

<?
if (@$_GET ['city']) {
$GLOBALS ['start_for_links'] = "city/" . htmlspecialchars ( $_GET ['city'] ) . "/";
$GLOBALS ['end_for_links'] = "sort/city_asc/page/1/";
} else {
$GLOBALS ['start_for_links'] = "";
$GLOBALS ['end_for_links'] = "sort/date_desc/page/1/";
}
$GLOBALS ['host'] = $h;
$GLOBALS ['count'] = 0;
function listcat2( $id, $sub, $count) {
$categories = mysql_query ( "SELECT * FROM jb_board_cat WHERE root_category = $id ORDER by sort_index" );
cq ();
while ( $category = mysql_fetch_assoc ( $categories ) ) {
echo ($category ['img'] != "") ? "<img align=left src=\"" . $GLOBALS ['host'] . "/upload/cat/" . $category ['img'] . "\">" : " ";
$kolvo = mysql_num_rows ( mysql_query ( "SELECT id from jb_board WHERE id_category = '" . $category ['id'] . "'" ) );
cq ();
if ($kolvo)
echo "<a href=\"" . $GLOBALS ['host'] . "/advertisement/" . @$GLOBALS ['start_for_links'] . "nesting/" . $category ['id'] . "/" . @$GLOBALS ['end_for_links'] . "\">" . $category ['name_cat'] . "&nbsp;[" . $kolvo . "]</a><br />";
else
echo $category ['name_cat'] . "<br />";
$GLOBALS ['count'] = $GLOBALS ['count'] + $kolvo;
listcat2 ( $category ['id'], $sub + 1, $GLOBALS ['count'] );
}
}
$categories = mysql_query ( "SELECT * FROM jb_board_cat WHERE root_category = 0 ORDER by sort_index" );
cq ();
$GLOBALS ['tdEnd'] = round ( mysql_num_rows ( $categories ) / 2 );
$GLOBALS ['count_rows'] = 0;
echo "<table width=100%><tr valign=top><td width=50% style=\"padding-right:10px;\">";
while ( $category = mysql_fetch_assoc ( $categories ) ) {
echo "<div style=\"margin-top:15px;\">";
echo ($category ['img'] != "") ? "<div style=\"float:left; margin-right:10px; \"><img align=left src=\"" . $GLOBALS ['host'] . "/upload/cat/" . $category ['img'] . "\"></div>" : " ";
echo "<H4><a href=# onClick=\"showhide('9999" . $category ['id'] . "','9s9" . $category ['id'] . "');return false;\" style=\"cursor:pointer\">" . $category ['name_cat'] . "</a> <span id=count_" . $category ['id'] . "></span></H4><div id=\"9s9" . $category ['id'] . "\" style=\"DISPLAY: block;\">" . $category ['description'] . "</div><div id=\"9999" . $category ['id'] . "\" style=\"DISPLAY: none; padding-left:0px\">";
$sub = 1;
listcat2 ( $category ['id'], $sub, $GLOBALS ['count'] );
echo "</div>";
if ($GLOBALS ['count'] != 0)
echo "<script type=\"text/javascript\">document.getElementById('count_" . $category ['id'] . "').innerHTML = '" . $GLOBALS ['count'] . "';</script>";
$GLOBALS ['count'] = 0;
echo "</div>";
$GLOBALS ['count_rows'] ++;
if ($GLOBALS ['count_rows'] % $GLOBALS ['tdEnd'] == "0")
echo "</td><td width=50%>";
}
echo "</td></tr></table>";
?>

FireFenix
12.08.2009, 13:53
чтобы убрать отображение подсчёта достаточно удалить

echo "<script type=\"text/javascript\">document.getElementById('count_" . $category['id'] . "').innerHTML = '" . $GLOBALS['count'] . "';</script>";

Для того чтобы вообще удалить подсчёт, то где-то так

<?php

if(@$_GET['city'])
{
$GLOBALS['start_for_links'] = "city/" . htmlspecialchars($_GET['city']) . "/";
$GLOBALS['end_for_links'] = "sort/city_asc/page/1/";
} else {
$GLOBALS['start_for_links'] = "";
$GLOBALS['end_for_links'] = "sort/date_desc/page/1/";
}

$GLOBALS['host'] = $h;

$categories = mysql_query("SELECT * FROM jb_board_cat WHERE root_category = 0 ORDER by sort_index");

cq();

$GLOBALS['tdEnd'] = round(mysql_num_rows($categories) / 2);
$GLOBALS['count_rows'] = 0;

echo "<table width=100%><tr valign=top><td width=50% style=\"padding-right:10px;\">";

while($category = mysql_fetch_assoc($categories))
{
echo "<div style=\"margin-top:15px;\">";
echo($category['img'] != "") ? "<div style=\"float:left; margin-right:10px; \"><img align=left src=\"" . $GLOBALS['host'] . "/upload/cat/" . $category['img'] . "\"></div>" : " ";
echo "<H4><a href=# onClick=\"showhide('9999" . $category['id'] . "','9s9" . $category['id'] . "');return false;\" style=\"cursor:pointer\">" . $category['name_cat'] . "</a> <span id=count_" . $category['id'] . "></span></H4><div id=\"9s9" . $category['id'] . "\" style=\"DISPLAY: block;\">" . $category['description'] . "</div><div id=\"9999" . $category['id'] . "\" style=\"DISPLAY: none; padding-left:0px\">";
echo "</div></div>";

$GLOBALS ['count_rows'] ++;

if($GLOBALS['count_rows'] % $GLOBALS['tdEnd'] == "0")
{
echo "</td><td width=50%>";
}
}

echo "</td></tr></table>";
?>

ufalog
13.08.2009, 20:05
спасибо с первым - помогло

вот такой же файл только чуть чуть изменен)

надо отключить именно запрос к бд ( чтоб снизить нагрузку



<div id="lbox" style="margin:6px 0">
<div id="box_t1"><?=$lang[598]?></div>
<div class="p">
<div id="cat_nav" >

<?
if (@$_GET['city']){
$GLOBALS['start_for_links'] = "city/".htmlspecialchars($_GET['city'])."/";
$GLOBALS['end_for_links'] = "sort/city_asc/page/1/";
}
else {
$GLOBALS['start_for_links'] = ""; $GLOBALS['end_for_links'] = "sort/date_desc/page/1/";
}

$GLOBALS['host'] = $h;
function listcat2($id, $sub)
{
$categories = mysql_query("SELECT * FROM jb_board_cat WHERE root_category = $id ORDER by name_cat");
while($category = mysql_fetch_array($categories))
{
$count = mysql_num_rows(mysql_query("SELECT * FROM jb_board WHERE old_mess = 'old' AND id_category='".$category['id']."' ".@$city_from_search));
$query = mysql_query("SELECT * FROM jb_board_cat WHERE root_category = ".$category['id']);
@$count_subcat_mthe_cat = mysql_num_rows($query);
if (@$GLOBALS['city_name_from_tips']) $tip_city = "".$GLOBALS['city_name_from_tips']; else $tip_city = "";
if(!@$count) echo "<span style='display:none;' href=\"".$GLOBALS['host']."/advertisement/".@$GLOBALS['start_for_links']."nesting/".$category['id']."/".@$GLOBALS['end_for_links']."\" >".$category['name_cat']."</span>";
else echo "<a href=\"".$GLOBALS['host']."/advertisement/".@$GLOBALS['start_for_links']."nesting/".$category['id']."/".@$GLOBALS['end_for_links']."\">".$category['name_cat']."&nbsp;(".$count.")</a>";
listcat2($category['id']);
}
}

$categories = mysql_query("SELECT * FROM jb_board_cat WHERE root_category = 0 ORDER by name_cat");
while($category = mysql_fetch_assoc($categories))
{

echo "<div onClick=\"details(9999".$category['id'].");\">".$category['name_cat']."</div><span id=\"9999".$category['id']."\" style=\"DISPLAY: none;\">";
listcat2($category['id']);
echo "</span>";
}
?> </div></div>
</div>

ufalog
13.08.2009, 22:43
убрать запрос на подсчет кол-ва объявлений и убрать вывод - чтоб снизить нагрузку на сервер