Amigos, estou montando um site de guia comercial, e estou precisando de uma forcinha na programação. Estarei deixando o site online, p/ que vocês possam melhor entender minha situação: http://201.78.173.188/guia Bom, é o seguinte, no canto direito encontra-se as cidades, e no canto esquerdo as categorias, ao clicar em uma cidade o botão Anuncios do lado esquerdo, mostra quantos comércios tem cadastrado naquela cidade. Por exemplo: Ao clicar em Aracruz, no canto esquerdo, você pode observar que o Anúncios vai estar com um (28) na frente, ou seja, nessa cidade tem 28 cadastros. Ao clicar nesse botão Anúncios, então, abre as subcategorias, ou seja, Restaurantes, Advocacias, etc.. O meu problema é o seguinte, eu queria que quando clicar na cidade, já fosse direto p/ essas subcategorias, sem ter a necessidade de ter que clicar no botão anúncios toda vez que mudar a cidade. Deixando assim, muito mais prático e profissional. alguém pode me ajudar, quanto a isso? Se possível, me adicione no MSN: danielpoltronieri@live.com Segue abaixo codigo do index e do cats-inc.php, que são os 'envolvidos' nisso: INDEX.php <?php
require_once("initvars.inc.php");
require_once("config.inc.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?php echo $page_title; ?></title>
<base href="<?php echo $script_url; ?>/">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $langx['charset']; ?>">
<meta name="keywords" content="<?php echo $meta_keywords; ?>">
<meta name="description" content="<?php echo $meta_description; ?>">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="pager.css">
<link rel="stylesheet" type="text/css" href="cal.css">
</head>
<body>
<div id="header">
</div>
<div id="menu">
<ul>
<li><a href="index.php?cityid=<?php echo $xcityid; ?>"><?php echo $lang['HOME_LINK']; ?></a></li>
<li><a href="<?php echo $postlink; ?>"><?php echo $lang['POST_LINK']; ?></a></li>
<?php if($enable_calendar) { ?>
<li><a href="<?php echo $posteventlink; ?>"><?php echo $lang['POST_EVENT_LINK']; ?></a></li>
<?php } ?>
<?php if($enable_images) { ?>
<li><a href="<?php echo $postimagelink; ?>"><?php echo $lang['POST_IMG_LINK']; ?></a><li>
<?php } ?>
<?php if($forum_dir) { ?>
<li><a href="<?php echo $forum_dir; ?>" target="_blank"><?php echo $lang['FORUM_LINK']; ?></a></li>
<?php } ?>
</ul>
</div>
<div id="barra_pesquisar">
<p class="encontre_aqui">Encontre aqui:</p>
<table width="90%" class="sidebox" cellspacing="0" align="center">
<div id="barra">
<?php include("search.inc.php"); ?>
</div>
<br>
</div>
<table width="770" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td colspan="3"><?php include("header.inc.php"); ?>
</td></tr>
<tr>
<?php
if ($xview == "main" || $show_sidebar_always)
{
?>
<td width="185" id="sidebar_left" valign="top">
<div id="categorias_top"></div>
<table width="90%" class="buttons" cellpadding="0" align="center">
</table>
<?php
if($xview != "post" && $xview != "postimg")
{
?>
<?php
}
?>
<table width="90%" class="sidebox" cellspacing="0" align="center">
<tr><td><?php include("cats.inc.php"); ?></td></tr>
</table><br>
<div id="categorias_bot"></div>
<?php
if ($enable_calendar && !$xpostmode)
{
?>
<table width="90%" cellspacing="0" class="sidebox" align="center">
<?php
$sql = "SELECT COUNT(*)
FROM $t_events a
INNER JOIN $t_cities ct ON a.cityid = ct.cityid
WHERE $visibility_condn
$loc_condn";
list($eventcount) = @mysql_fetch_array(mysql_query($sql));
$eventcount = 0+$eventcount;
?>
<tr><th class="head"><?php echo $lang['EVENT_CALENDAR']; ?> (<?php echo $eventcount; ?>)</th></tr>
<tr><td>
<br>
<?php
if($sef_urls) $url = "{$vbasedir}$xcityid/events/{@Y}-{@M}-{@D}/";
else $url = "?view=events&date={@Y}-{@M}-{@D}&cityid=$xcityid&lang=$xlang";
echo calendar::display($url, $langx['firstweekday'], $langx['weekdays'], $langx['months'], $_GET['_xzcal_y'], $_GET['_xzcal_m'], $specialdates);
?>
<br>
</td></tr>
<tr><td align="center">
<?php
$date = date("Y-m-d");
$sql = "SELECT COUNT(*)
FROM $t_events a
INNER JOIN $t_cities ct ON a.cityid = ct.cityid
WHERE starton <= '$date' AND endon >= '$date'
AND $visibility_condn
$loc_condn";
list($eventstoday) = @mysql_fetch_array(mysql_query($sql));
$eventstoday = 0+$eventstoday;
?>
<div align="center">
<?php
$today = date("Y-m-d");
if ($sef_urls) $events_url = "{$vbasedir}$xcityid/events/$today";
else $events_url = "?view=events&date=$today&cityid=$xcityid&lang=$xlang";
if ($sef_urls) $upcoming_events_url = "{$vbasedir}$xcityid/events/";
else $upcoming_events_url = "?view=events&cityid=$xcityid&lang=$xlang";
?>
<b>
<a href="<?php echo $events_url; ?>"><?php echo $eventstoday; ?> <?php echo $lang['X_EVENTS_TODAY']; ?></a><br>
<a href="<?php echo $upcoming_events_url; ?>">Todos Eventos</a><br><br>
<a href="<?php echo $posteventlink; ?>"><?php echo $lang['POST_EVENT_LINK']; ?></a>
</b>
</div>
</td></tr>
</table><br><br>
<?php
}
?>
<?php
if ($enable_images && ($xview == "main" || $xsection == "imgs"))
{
$sql = "SELECT COUNT(*) as imgcnt
FROM $t_imgs a
INNER JOIN $t_cities ct ON a.cityid = ct.cityid
WHERE $visibility_condn AND ct.enabled = '1'
$loc_condn_img";
list($imgcnt) = @mysql_fetch_array(mysql_query($sql));
?>
<table width="90%" cellspacing="0" class="sidebox" align="center">
<tr><th class="head"><?php echo $lang['IMAGES']; ?> (<?php echo $imgcnt; ?>)</th></tr>
<tr><td>
<div align="center">
<?php
$rand = rand(0, $imgcnt-1);
$sql = "SELECT a.*, UNIX_TIMESTAMP(a.createdon) AS createdon
FROM $t_imgs a
INNER JOIN $t_cities ct ON a.cityid = ct.cityid
WHERE $visibility_condn
$loc_condn_img
LIMIT $rand, 1";
$img = @mysql_fetch_array(mysql_query($sql));
if ($img)
{
$posterenc = EncryptPoster("IMG", $img['postername'], $img['posteremail']);
if($sef_urls) $imgurl = "{$vbasedir}$xcityid/images/$posterenc/$img[imgid].html";
else $imgurl = "?view=showimg&posterenc=$posterenc&imgid=$img[imgid]&cityid=$xcityid&lang=$xlang";
if($sef_urls) $allimgurl = "{$vbasedir}$xcityid/images/";
else $allimgurl = "?view=imgs&cityid=$xcityid&lang=$xlang";
$imgsize = GetThumbnailSize("{$datadir[userimgs]}/{$img[imgfilename]}", $smallthumb_max_width, $smallthumb_max_height);
?>
<br>
<a href="<?php echo $imgurl; ?>">
<img src="<?php echo "{$datadir[userimgs]}/{$img[imgfilename]}"; ?>" border="0" class="thumb" id="latestimg" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>"></a><br>
<br>
<b><?php echo $img['imgtitle']; ?></b><br>
<?php echo $lang['POSTED_BY']; ?> <b><?php echo $img['postername']; ?></b>
<br>
<?php
}
?>
<br>
<b><a href="<?php echo $allimgurl; ?>"><?php echo $lang['ALL_IMAGES']; ?></a></b>
<br>
<b><a href="?view=postimg&cityid=<?php echo $xcityid; ?>&lang=<?php echo $xlang; ?>"><?php echo $lang['POST_IMG_LINK']; ?></a></b>
</div>
</td></tr>
</table>
<?php
}
?>
<br>
<table width="90%" cellspacing="0" class="sidebox" align="center"><tr><td align="left">
<?php include("sidebar_left.inc.php"); ?>
</td></tr></table>
</td>
<?php
}
?>
<td valign="top" id="contentcell">
<?php include("path.inc.php"); ?>
<div style="display:none;"><?php echo "<!--#&88;#&90;#&101;#&114;#&111;".
"#&83;#&99;#&114;#&105;#&112;#&116;#&115;#&46;#&99;#&111;#&109;-->"; ?></div>
<table width="100%" cellspacing="0" cellpadding="0"><tr>
<td id="content">
<?php
switch($xview)
{
case "subcats" : $page = "subcats.php"; break;
case "ads" :
case "events" : $page = "ads.php"; break;
case "showad" :
case "showevent" : $page = "showad.php"; break;
case "post" : $page = "post.php"; break;
case "edit" : $page = "edit.php"; break;
case "imgs" : $page = "imgs.php"; break;
case "showimg" : $page = "showimg.php"; break;
case "postimg" : $page = "postimg.php"; break;
case "editimg" : $page = "editimg.php"; break;
case "activate" : $page = "activate.php"; break;
case "selectcity" : $page = "selectcity.php"; break;
case "mailad" : $page = "mailad.php"; break;
case "page" : if (isCustomPage($_GET['pagename'])) { $page = "$_GET[pagename].php"; } break;
}
include_once($page);
?>
</td>
</tr></table>
</td>
<?php if($xview == "main") { ?>
<td width="190" valign="top" id="sidebar_right_cities">
<?php include("cities.inc.php"); ?>
</td>
<?php } elseif($show_right_sidebar) { ?>
<td width="1" valign="top" id="sidebar_right">
<?php include("cities.inc.php"); ?>
</td>
<?php } ?>
</tr>
</table>
<?php include("footer.inc.php"); ?>
</body>
</html>
CATS.INC.PHP:
<div class="catlist">
<?php
// List of categories
if($dir_sort)
{
$sortcatsql = "ORDER BY catname";
$sortsubcatsql = "ORDER BY subcatname";
}
else
{
$sortcatsql = "ORDER BY pos";
$sortsubcatsql = "ORDER BY scat.pos";
}
// First get ads per cat and subcat
$subcatadcounts = array();
$catadcounts = array();
$sql = "SELECT scat.subcatid, scat.catid, COUNT(*) as adcnt
FROM $t_ads a
INNER JOIN $t_subcats scat ON scat.subcatid = a.subcatid AND ($visibility_condn)
INNER JOIN $t_cats cat ON cat.catid = scat.catid
INNER JOIN $t_cities ct ON a.cityid = ct.cityid
WHERE scat.enabled = '1'
$loc_condn
GROUP BY a.subcatid";
$res = mysql_query($sql) or die(mysql_error().$sql);
while($row=mysql_fetch_array($res))
{
$subcatadcounts[$row['subcatid']] = $row['adcnt'];
$catadcounts[$row['catid']] += $row['adcnt'];
}
// Categories
$sql = "SELECT catid, catname AS catname FROM $t_cats WHERE enabled = '1' $sortcatsql";
$rescats = mysql_query($sql) or die(mysql_error());
$catcount = @mysql_num_rows($rescats);
$percol_short = floor($catcount/$dir_cols);
$percol_long = $percol_short+1;
$longcols = $catcount%$dir_cols;
$i = 0;
$j = 0;
$col = 0;
$thiscolcats = 0;
while($rowcat=mysql_fetch_array($rescats))
{
if ($j >= $thiscolcats)
{
$col++;
$thiscolcats = ($col > $longcols) ? $percol_short : $percol_long;
$j = 0;
}
$i++;
$j++;
$catname_inurl = RemoveBadURLChars($rowcat['catname']);
if($sef_urls) $catlink = "{$vbasedir}$xcityid/posts/$rowcat[catid]_{$catname_inurl}/0/";
else $catlink = "?view=ads&catid=$rowcat[catid]&cityid=$xcityid&lang=$xlang";
$adcount = 0+$catadcounts[$rowcat['catid']];
?>
<div class="cat">
<img src="images/bullet.gif" align="absmiddle"> <a href="<?php echo $catlink; ?>"><?php echo $rowcat['catname']; ?></a>
<?php if($show_cat_adcount) { ?><span class="count">(<?php echo $adcount; ?>)</span><?php } ?>
</div>
<?php
if($xcatid == $rowcat['catid'])
{
$sql = "SELECT scat.subcatid, scat.subcatname AS subcatname
FROM $t_subcats scat
WHERE scat.catid = $rowcat[catid]
AND scat.enabled = '1'
$sortsubcatsql";
$ressubcats = mysql_query($sql) or die(mysql_error()."<br>$sql");
while ($rowsubcat = mysql_fetch_array($ressubcats))
{
$adcount = 0+$subcatadcounts[$rowsubcat['subcatid']];
if($sef_urls) $subcat_url = "{$vbasedir}$xcityid/posts/$rowcat[catid]_{$catname_inurl}/$rowsubcat[subcatid]_". RemoveBadURLChars($rowsubcat['subcatname'])."/";
else $subcat_url = "?view=ads&catid=$rowcat[catid]&subcatid=$rowsubcat[subcatid]&cityid=$xcityid&lang=$xlang";
?>
<div class="subcat">
<a href="<?php echo $subcat_url; ?>"><?php echo $rowsubcat['subcatname']; ?></a>
<?php if($show_subcat_adcount) { ?><span class="count">(<?php echo $adcount; ?>)</span><?php } ?>
</div>
<?php
}
}
}
?>
</div> Grato!