2015-08-19 143 views
0

我有一個網站如OLX.com使用過的產品買賣,索引頁有城市過濾器下拉列表,一旦用戶點擊過濾器,他將只看到他的產品過濾器城市和重定向到頁面city_filter.php到現在一切正常, 經過城市篩選後,當用戶點擊任何類別,如計算機或電子用戶沒有發現任何產品,所有類別都來自mysql數據庫,city_filter.php包括function_city.php調用函數的所有類別,請在function_city.php上找到city_filter.php函數,如下所示: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,我使用提及功能只能從過濾市

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>"; 
} 
}  
} 

我想我不會用正確的去,爲什麼,因爲我注意到過濾電腦時,我點擊需要使用GET方法接收的計算機類別computer_cat = id,並且一旦點擊類別城市ID會話丟失,我不知道這種情況的做法。

+1

$ _SESSEION ['city_id']錯字? – Naruto

回答

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";