我有一个网站,如OLX.com用于二手产品买卖,索引页面有城市过滤器下拉列表,一旦用户点击过滤器,他将只看到他的过滤器城市的产品并重定向到页面city_filter.php
到现在为止一切正常,
在城市过滤后,当用户点击任何类别,如计算机或电子用户未找到任何产品时,所有类别都来自mysql数据库,city_filter.php
包含function_city.php
用于所有类别的调用功能,请查找{{ 1}}在city_filter.php
上创建的函数如下:
function_city.php
在function displaycomputer_city(){
global $con;
$get_cats = "select * from categories where categories_id = 1";
$run_cats = mysqli_query($con, $get_cats);
while ($row_cats=mysqli_fetch_array($run_cats)) {
$computer_id = $row_cats['categories_id'];
$computer_title = $row_cats['categories_name'];
echo "<li><a href='city_filter.php?computer_cat=$computer_id'>$computer_title</a></li>";
}
}
页面上,当我点击计算机时,它会占用浏览器city_filter.php
而我正在使用提及功能仅过滤来自过滤器城市的计算机
computer_cat=id
我认为我没有找到正确的原因,因为当我点击计算机类别时我注意到它需要使用GET方法接收function getcomputerpro_city() {
global $con;
global $eu;
global $limit;
if(isset($_GET['computer_cat'])){
$cat_id = $_GET ['computer_cat'];
$get_products = "SELECT product_list.*, city1.* FROM product_list INNER JOIN city1 ON product_list.city_id=city1.city_id AND product_list.city_id={$_SESSEION['city_id']} AND categories_id='$cat_id' limit $eu, $limit";
foreach ($con->query($get_products) as $row) {
echo "<div class='ser-grid-list'>
<h5>$row[product_title]</h5>
<img src='admin_area/product_images/$row[image_1]' width='160' height='110' alt=''>
<p>Price : $row[currency] $row[product_price]</p>
<p>City : $row[city_name]</p>
<p>Date : $row[date]</p>
<div class='btn top'><a href='details.php?pro_id=$row[list_id]'>View More</a></div>
</div>";
}
}
}
,并且一旦点击类别城市ID会话丢失,我就不会这种情况的做法是什么?
答案 0 :(得分:1)
如果您在每个页面的开头都包含session_start();
,并且如果您没有取消设置/销毁会话,那么您在此处输入错误信息:
改变这个:
$get_products = "SELECT product_list.*, city1.* FROM product_list INNER JOIN city1 ON product_list.city_id=city1.city_id AND product_list.city_id={$_SESSEION['city_id']} AND categories_id='$cat_id' limit $eu, $limit";
到此:
$get_products = "SELECT product_list.*, city1.* FROM product_list INNER JOIN city1 ON product_list.city_id=city1.city_id AND product_list.city_id={$_SESSION['city_id']} AND categories_id='$cat_id' limit $eu, $limit";