求php多条件搜索后分页代码
代码如下:不知道如何更改<?include"search_dg/sql.php";$page=empty($_GET['page'])?1:intval($_GET['p...
代码如下:不知道如何更改
<?
include "search_dg/sql.php";
$page = empty($_GET['page']) ? 1 : intval($_GET['page']);
unset($_GET['page']);
$query_string_prefix = my_http_build_query($_GET);
$query_string_prefix = empty($query_string_prefix) ? '' : $query_string_prefix.'&';
$cond="where (1=1)";
if ($_GET["New"]!="") {$New=$_GET["New"];$cond="$cond and New LIKE '%$New%'";}
if ($_GET["Old"]!="") {$Old=$_GET["Old"];$cond="$cond and Old LIKE '%$Old%'";}
if ($_GET["Impedance1"]!="" or $_GET["Impedance2"]!="" ) {$Impedance1=$_GET["Impedance1"];$Impedance2=$_GET["Impedance2"];$cond="$cond and Impedance between $Impedance1 and $Impedance2";}
if ($_GET["FREQ"]!="") {$FREQ=$_GET["FREQ"];$cond="$cond and FREQ ='$FREQ'";}
if ($_GET["DCR"]!="") {$DCR=$_GET["DCR"];$cond="$cond and DCR ='$DCR'";}
if ($_GET["DCR1"]!="" or $_GET["DCR2"]!="" ) {$DCR1=$_GET["DCR1"];$DCR2=$_GET["DCR2"];$cond="$cond and DCR between $DCR1 and $DCR2";}
if ($_GET["IDC"]!="") {$IDC=$_GET["IDC"];$cond="$cond and IDC ='$IDC'";}
$show = select_sql("SELECT * FROM `search_two` $cond LIMIT $page ,10 ");
//$total = count($show);
$total = count( select_sql(" SELECT * FROM `search_two` $cond "));
$total_one = count( select_sql(" SELECT * FROM `search_two` "))/10;
?>
<?
for($i=0;$i<count($show);$i++)
{
?>
<tr bgcolor="#EEFFFF" class="style57">
<td width="42" class="english7"><span class="style89">
<?=$show[$i][0]?>
</span> </td>
<td width="148" class="english7"><span class="style89">
<?=$show[$i][1]?>
</span></td>
<td width="155" class="english7"><span class="style89">
<?=$show[$i][2]?>
</span></td>
<td width="105" class="english7"><span class="style89">
<?=$show[$i][3]?>
</span></td>
<td width="67" class="english7"><span class="style89">
<?=$show[$i][4]?>
</span></td>
<td width="59" class="english7"><span class="style89">
<?=$show[$i][5]?>
</span></td>
<td width="90" class="english7"><span class="style89">
<?=$show[$i][6]?>
</span></td>
<?
}
?> </tr>
</table>
</div>
</p>
</p>
<div align="center">
<?
for ($i=1; $i<$total_one; $i++) {
if ( $i == $page) {
echo '<a>'.$i.'</a> ';
} else {
echo '<a href="show_three.php?'.$query_string_prefix.'page='.$i.'">'.$i.'</a> ';
}
}
function my_http_build_query($params) {
$ret = '';
foreach ($params as $k => $v) {
$ret[] = rawurlencode($k).'='.rawurlencode($v);
}
return implode('&', $ret);
}
?>
qq122195648 ,求 像/// 1 2 3 4 5 下页 //的分页。谢谢!好了再送分。 展开
<?
include "search_dg/sql.php";
$page = empty($_GET['page']) ? 1 : intval($_GET['page']);
unset($_GET['page']);
$query_string_prefix = my_http_build_query($_GET);
$query_string_prefix = empty($query_string_prefix) ? '' : $query_string_prefix.'&';
$cond="where (1=1)";
if ($_GET["New"]!="") {$New=$_GET["New"];$cond="$cond and New LIKE '%$New%'";}
if ($_GET["Old"]!="") {$Old=$_GET["Old"];$cond="$cond and Old LIKE '%$Old%'";}
if ($_GET["Impedance1"]!="" or $_GET["Impedance2"]!="" ) {$Impedance1=$_GET["Impedance1"];$Impedance2=$_GET["Impedance2"];$cond="$cond and Impedance between $Impedance1 and $Impedance2";}
if ($_GET["FREQ"]!="") {$FREQ=$_GET["FREQ"];$cond="$cond and FREQ ='$FREQ'";}
if ($_GET["DCR"]!="") {$DCR=$_GET["DCR"];$cond="$cond and DCR ='$DCR'";}
if ($_GET["DCR1"]!="" or $_GET["DCR2"]!="" ) {$DCR1=$_GET["DCR1"];$DCR2=$_GET["DCR2"];$cond="$cond and DCR between $DCR1 and $DCR2";}
if ($_GET["IDC"]!="") {$IDC=$_GET["IDC"];$cond="$cond and IDC ='$IDC'";}
$show = select_sql("SELECT * FROM `search_two` $cond LIMIT $page ,10 ");
//$total = count($show);
$total = count( select_sql(" SELECT * FROM `search_two` $cond "));
$total_one = count( select_sql(" SELECT * FROM `search_two` "))/10;
?>
<?
for($i=0;$i<count($show);$i++)
{
?>
<tr bgcolor="#EEFFFF" class="style57">
<td width="42" class="english7"><span class="style89">
<?=$show[$i][0]?>
</span> </td>
<td width="148" class="english7"><span class="style89">
<?=$show[$i][1]?>
</span></td>
<td width="155" class="english7"><span class="style89">
<?=$show[$i][2]?>
</span></td>
<td width="105" class="english7"><span class="style89">
<?=$show[$i][3]?>
</span></td>
<td width="67" class="english7"><span class="style89">
<?=$show[$i][4]?>
</span></td>
<td width="59" class="english7"><span class="style89">
<?=$show[$i][5]?>
</span></td>
<td width="90" class="english7"><span class="style89">
<?=$show[$i][6]?>
</span></td>
<?
}
?> </tr>
</table>
</div>
</p>
</p>
<div align="center">
<?
for ($i=1; $i<$total_one; $i++) {
if ( $i == $page) {
echo '<a>'.$i.'</a> ';
} else {
echo '<a href="show_three.php?'.$query_string_prefix.'page='.$i.'">'.$i.'</a> ';
}
}
function my_http_build_query($params) {
$ret = '';
foreach ($params as $k => $v) {
$ret[] = rawurlencode($k).'='.rawurlencode($v);
}
return implode('&', $ret);
}
?>
qq122195648 ,求 像/// 1 2 3 4 5 下页 //的分页。谢谢!好了再送分。 展开
展开全部
我看你代码都写好了的呀,只是引号使用不对,我给你修改如下:
for ($i=1; $i<$total_one; $i++) {
if ( $i == $page) echo "<a>$i</a>";
else echo "<a href='show_three.php?{$query_string_prefix}&page=$i'>$i</a>";
}
for ($i=1; $i<$total_one; $i++) {
if ( $i == $page) echo "<a>$i</a>";
else echo "<a href='show_three.php?{$query_string_prefix}&page=$i'>$i</a>";
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我看你代码都写好了的呀,只是引号使用不对,我给你修改如下:
for
($i=1;
$i<$total_one;
$i++)
{
if
(
$i
==
$page)
echo
"<a>$i</a>";
else
echo
"<a
href='show_three.php?{$query_string_prefix}&page=$i'>$i</a>";
}
for
($i=1;
$i<$total_one;
$i++)
{
if
(
$i
==
$page)
echo
"<a>$i</a>";
else
echo
"<a
href='show_three.php?{$query_string_prefix}&page=$i'>$i</a>";
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for ($i=1; $i<$total_one; $i++) {
if ( $i == $page) echo "<a>$i</a>";
else echo "<a href='show_three.php?{$query_string_prefix}&page=$i'>$i</a>";
}
if ( $i == $page) echo "<a>$i</a>";
else echo "<a href='show_three.php?{$query_string_prefix}&page=$i'>$i</a>";
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询