PHP链接只传递部分mysql结果

时间:2012-11-07 15:13:00

标签: php

好的,我有一个由几个变量组成的php链接

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

整个代码很长,因为它有很多分页,所以我将只包括基本查询和循环部分。

$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 个答案:

答案 0 :(得分:0)

尝试传递它:

'.urlencode($model_type).'

尝试使用 urldecode($_REQUEST['$model_type'])

在下一页访问它

答案 1 :(得分:-1)

我不是一般的,但你可能缺少编码问题。

试试这个:

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

它的url_encoding值,所以你的url不会被',',空格等打破。

额外提示: 用“或”附上您的网址,以便最后不会出现问题。