2012-11-07 51 views
-1

確定我有一個由幾個變量PHP鏈接只有通過一個MySQL結果的一部分

<a href=\year.php? manufacturer='.$manufacturer.'&fuel_type='.$fuel_type.'&model_type='.$model_type.'>'.$model_type.'</a> 

整個代碼是很長的,因爲它有很多分頁的一個PHP鏈接,所以我只是包括基本查詢和循環部分。

$query1 = "SELECT Distinct model_type from $tableName where manufacturer='$manufacturer' AND fuel='$fuel_type' LIMIT $start, $limit"; 
$result = mysql_query($query1); 

然後我得到並顯示結果的底部。

$count = 0; 
$max = 2; 
while($row = mysql_fetch_array($result)) 
    { 
$model_type = $row['model_type'];    
$count++; 
echo '<td class="manu"><div align="center">'.'<a href=\year.php? manufacturer='.$manufacturer.'&fuel_type='.$fuel_type.'&model_type='.$model_type.'>'.$model_type.'</a>'.'</div></td>'; 

if($count >= $max){ 
    //reset counter 
    $count = 0; 
    //end and restart 
    echo '</tr><tr>'; 
    } 

    } 

現在這工作得很好,除了當我從它顯示爲1系列數據庫模式類型變量,但是當它在這個環節只得到1和不拿起系列傳遞。

感謝

+2

訪問下一頁您沒有提供有效的PHP語法。很難知道,如果這是一個現有的字符串 – codingbiz

+1

哪個是「模式類型」變量的一部分?什麼是系列?你可以顯示你的數據庫查詢嗎?並給出一個錯誤的樣本以及所需的URL。 – mario

+0

可能是空白問題。你能發佈完整的代碼嗎? – Mob

回答

-1

我不是舒爾但你可能有失蹤的編碼問題。

試試這個:

<a href="\year.php? manufacturer='.urlencode($manufacturer).'&fuel_type='.urlencode($fuel_type).'&model_type='.urlencode($model_type).'">'.$model_type.'</a> 

其url_encoding數值,以便您的網址犯規被獲得破「‘空格等

額外提示: 附上您的網址是以’或」使最後你不會遇到問題。

+0

感謝該工作完全 –

0

試圖通過它喜歡:

'.urlencode($model_type).' 

嘗試與urldecode($_REQUEST['$model_type'])

+0

thatnks返回5 +系列,而不是5系是在列 –

+0

當你訪問它的下一個頁面會得到它的權利。 –