2012-11-07 48 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

当你访问它的下一个页面会得到它的权利。 –