2012-02-15 212 views
0

我正在尝试构建一个搜索网站,在这里您可以优化您的搜索,但即时通过新的$获取值时遇到问题...我将链接我得到的示例和我很难实现,如果有任何帮助我apreciate。带搜索引擎的PHP搜索引擎

我想实现什么? http://www.pac.com.ve/index.php?option=com_jumi&fileid=9&Itemid=119&keyword=farmacia

我得到了什么? http://www.laguiadelveterinario.com/test/test_array.php?category=cat2

我无法找到一种方法来更新GET变量,当我点击左边的菜单。

+0

你在浏览器中获得的变量?确切的问题是什么? – dee 2012-02-15 22:41:30

+0

你需要在你的php代码中写入'<?php if($ _ GET ['xyz']){do blah} else {blah}' – dee 2012-02-15 22:42:39

回答

0

是啊,我一直在这里看着周围2个选择:

1.-的$ _Get方法传递变量通网址

2:创建一个赛季,并添加值作为用户点击diferents选项。

在使用GET方法的那一刻IM但我不能找到如何删除筛选链接,当点击删除GET值....所以我在浏览各地,并找出赛季方法,我也会

0

我想出了这个解决方案...我通过变量直通Get方法,工作完美,但我在URL中得到空值...

你可以看到这里的工作示例:http://www.laguiadelveterinario.com/test/test_array.php?category=cat3

注1:在顶级lvl菜单中,只有(clasificados)上的项目才是最右边的按钮......上面有一些数据注意2:显示不同子类别(用户将点击以优化搜索的用户)的左侧菜单仍然是静态的,点击菜单上的某些东西时它不刷新...

注3:我只学尝试由现在的测试代码以删除状态过滤器...

问:我是朝着正确的方向吗?我可以动态添加/删除不同的变量吗?我应该使用数组吗?感谢任何帮助,我可以使用。

病现在粘贴代码:

<?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 />\n"; 
     } 
    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 />\n"; 
     /*echo "<a href=\"getsubcat.php?category=$cat&estado=". $row['estado'] ."\"> Hay " . $row['COUNT(name)'] ." en ". $row['estado'] . "</a><br />\n";*/ 
    } 
    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 />\n"; 
     }  } 
    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>