i'm trying to build a search site where u can be able to refine your search but im having trouble passing the new $get value... i'll link the examples of what i got and what i awant to achieve, if any help i apreciate.
What i want to achieve? http://www.pac.com.ve/index.php?option=com_jumi&fileid=9&Itemid=119&keyword=farmacia
What i got? http://www.laguiadelveterinario.com/test/test_array.php?category=cat2
I cant find a way to update the GET variable when i click on the left menu.
yeah, i'd been looking around 2 options here:
1.- the $_Get method passing the variables thru the url
2.- creating a season and add the values as the users click on the diferents options.
at the moment im using the get method but i cant find how to remove the get value when clicking on the remove filter link.... so i was browsing around and find out the season method which im gonna
i came up with this solution... i pass the variables thru the Get method, is working perfectly but i get empty values in the URL...
You can see the working example here: http://www.laguiadelveterinario.com/test/test_array.php?category=cat3
Note 1: in the top lvl menu, there are only items on (clasificados) that will be the farest right button... theres some data only on (buscando hogar, enrazate, se busca)
Note 2: the left menu that shows diferent subcategories (which users will click to refine search) still static, it doesnt refresh when click something on the menu yet...
Note 3: i only attemp to remove the state filter by now for testing code...
Question: Am i going in the right direction? can i add/remove the diferent variables dynamically? should i use array for that? thanks for any help i could use.
ill paste the code now:
<?php
$cat = $_GET['category'];
$estado = $_GET['estado'];
$tmascota = $_GET['tmascota'];
$raza = $_GET['raza'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test Array</title>
<link rel="stylesheet" type="text/css" href="css/pro_drop_1.css" />
<style>
body{margin:40px;}
</style>
</head>
<body>
<div style=" clear:left; padding:40px;">
<?php include 'menu.php'; ?>
</div>
<div style="float:left; border:1px solid #999; padding:30px;"><h1>Por categorias: </h1>
<?php
include 'conexion.php';
include('ps_pagination.php');
echo "<b>Por Estados: </b><br />";
$citys = mysql_query("SELECT estado, COUNT(name) FROM clasificados WHERE clasificados.category = '$cat' GROUP BY estado");
while ($row = mysql_fetch_array($citys)) {
echo "<a href=\"test_array.php?category=".$cat."&estado=". $row['estado'] ."&tmascota=".$tmascota."&raza=".$raza."\"> Hay " . $row['COUNT(name)'] ." en ". $row['estado'] . "</a><br />
";
}
mysql_free_result($citys);
echo "<b>Por Tipos de Mascotas: </b><br />";
$mascotas = mysql_query("SELECT tmascota, COUNT(name) FROM clasificados WHERE clasificados.category = '$cat' GROUP BY tmascota");
while ($row = mysql_fetch_array($mascotas)) {
echo "<a href=\"test_array.php?category=".$cat."&estado=". $estado ."&tmascota=". $row['tmascota'] ."&raza=".$raza."\"> Hay " . $row['COUNT(name)'] ." en ". $row['tmascota'] . "</a><br />
";
/*echo "<a href=\"getsubcat.php?category=$cat&estado=". $row['estado'] ."\"> Hay " . $row['COUNT(name)'] ." en ". $row['estado'] . "</a><br />
";*/
}
mysql_free_result($mascotas);
echo "<b>Por Razas: </b><br />";
$qryraza = mysql_query("SELECT raza, COUNT(name) FROM clasificados WHERE clasificados.category = '$cat' GROUP BY raza");
while ($row = mysql_fetch_array($qryraza)) {
echo "<a href=\"test_array.php?category=".$cat."&estado=". $estado ."&tmascota=". $tmascota ."&raza=". $row['raza'] ."\"> Hay " . $row['COUNT(name)'] ." en ". $row['raza'] . "</a><br />
";
} }
mysql_free_result($qryraza);
echo "<p><a href=\"test_array.php?category=".$cat."&estado=&tmascota=". $tmascota ."&raza=".$raza."\">remove (estado) filter</a></p>";
?></div><?
$sql = "SELECT * FROM clasificados WHERE 1=1";
if(isset ($cat))
{
$sql .= " AND category='$cat'";
}
if(isset ($cat) && ($estado))
{
$sql .= " AND clasificados.category='$cat' AND clasificados.estado='$estado'";
}
if(isset ($cat) && ($tmascota))
{
$sql .= " AND clasificados.category='$cat' AND clasificados.tmascota='$tmascota'";
}
if(isset ($cat) && ($raza))
{
$sql .= " AND clasificados.category='$cat' AND clasificados.raza='$raza'";
}
$sql .= " ORDER BY clasificados.id DESC";
$counttotal = mysql_query($sql) or die(mysql_error()) ;
$counttotal = mysql_num_rows($counttotal);
$pager = new PS_Pagination($conn, $sql, 6, 5, "category=$cat");
$pager->setDebug(true);
$rs = $pager->paginate();
if(!$rs) die(mysql_error());
?>
<div style="float:left;border:1px solid #999; padding:30px;"><h1>Resultados <? echo $counttotal; ?></h1>
<?
while($row = mysql_fetch_assoc($rs)) {
echo "<div style=\"clear:left;border:1px solid #999; padding:30px;\">Title: ".$row['title']."<br />".
"Estado: ".$row['estado']."<br />".
"Tipo Mascota: ".$row['tmascota']."<br />".
"Raza: ".$row['raza']."<br />".
"</div>";
}
?>
</div>
<div style="float:left;border:1px solid #999; padding:30px;"><h1>Print Variables</h1><?
echo "categoria: ".$cat."<br />";
echo "estado: ".$estado."<br />";
echo "tmascota: ".$tmascota."<br />";
echo "raza: ".$raza."<br />";
?>
</body>