做了一个php 多重查询,想实现分页显示(每页显示十条记录),结果却是第一页能显示出来,后面的页数显示不出来,一直有这个warning:Warning: implode() [function.implode]: Invalid arguments passed in D:\Appache\AppServ\www\webpage.php on line 68, 怎么回事?好像是那个数组得值没有被接收到,高手给指导下,data.php //查询的页面 <form action="./webpage.php" method="get" name="form1" >
<th valign="top" class="STYLE6" scope="col"><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<th width="28%" scope="col"><p class="STYLE22">Filter by County</p>
<p>
<select name="county[]" size="15" multiple class="textbox" >
<option value="-1" selected="selected">All Counties</option>
<option value="1">Adams</option>
<option value="2">Antelope</option>
<option value="3">Arthur</option>
<option value="4">Banner</option>
<option value="5">Blaine</option>
<option value="6">Boone</option>
<option value="7">Box Butte</option>
<option value="8">Boyd</option>
<option value="9">Brown</option>
<option value="10">Buffalo</option>
<option value="11">Burt</option>
<option value="12">Butler</option>
<option value="13">Cass</option>
<option value="14">Cedar</option>
<option value="15">Chase</option>
<option value="16">Cherry</option>
<option value="17">Cheyenne</option>
<option value="18">Clay</option>
<option value="19">Colfax</option>
<option value="20">Cuming</option>
</select>
</p></th>
<th width="40%" valign="top" scope="col"><p class="STYLE22">Filter by Crop Type</p>
<p>
<select name="croptype[]" size="6" multiple class="textbox">
<option value="-1" selected="selected">All Crop Types</option>
<option value="2">Fruit or Vegetables</option>
<option value="1">Grapes(vineyards)</option>
<option value="3">Honey</option>
<option value="4">Nursery (ornamental plants, plants for seed, flowers/cut flowers, etc)</option>
<option value="5">Orchard (trees for fruit/nuts)</option>
<option value="6">Organic</option>
<option value="7">Other</option>
</select>
</p></th>
<th width="32%" valign="top" scope="col"><p class="STYLE22">Filter by Date<!--1233 --></p>
<p class="STYLE22">
<label>
<input name="dt" type="date" id="textfield" size="15" class ="textbox">
</label>
</p>
<p align="center" class="STYLE22 style33">If a date is entered, records on or after that date will be returned. <span class="style34">(Format: mm/dd/yyyy e.g. 01/20/2010)</span></p>
<p class="STYLE22"> </p></th>
</tr>
<tr>
<td height="19" colspan="2"> </td>
<! [if IE]>
<input type="text" style="display: none;" disabled="disabled" size="1" /><![sendif]>
</tr>
</table>
<div align="center">
<p class="style25"> To select multiple counties or crop types, hold down the control key and select the items to include in your report. </p>
<p>
<input name="submit" type="submit" value="Submit">
</p>
</div>
</form>
<form action=" " method="get" name="form2" >
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
</form>
webpage.php //后台
<?php$conn=mysql_connect("localhost","","");
if (!$conn) {
die("Could not select db: ".mysql_error());
}
mysql_select_db("vineyard",$conn);
$perpagenum = 10;
$total = mysql_fetch_array(mysql_query("select count(*) from data_query", $conn));
$Total = $total[0];
$Totalpage = ceil($Total/$perpagenum);
if(!isset($_GET['page'])||!intval($_GET['page'])||$_GET['page']>$Totalpage)
{
$page=1;
}
else
{
$page=$_GET['page'];
}
$startnum = ($page-1)*$perpagenum;$county=$_GET['county'];$croptype=$_GET['croptype'];$dt = date('Y-m-d', strtotime($_GET["dt"]));if (implode(",", $county) != "-1" and implode(",", $croptype) != "-1" and $dt != "")
{
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid IN (".implode(",", $county).") AND cropid IN (".implode(",", $croptype).") AND Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) =="-1" and implode(",", $croptype) != "-1" and $dt != ""){
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE cropid in (".implode(",", $croptype).") AND Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) != "-1" and implode(",", $croptype)== "-1" and $dt != ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid in (".implode(",", $county).") AND Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) == "-1" and implode(",", $croptype)== "-1" and $dt != ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) != "-1" and implode(",", $croptype) != "-1" and $dt == "")
{
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid in (".implode(",", $county).") AND cropid in (".implode(",", $croptype).") ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county)=="-1" and implode(",", $croptype) != "-1" and $dt == ""){
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE cropid in (".implode(",", $croptype).") ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) != "-1" and implode(",", $croptype)== "-1" and $dt == ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid in (".implode(",", $county).") ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) == "-1" and implode(",", $croptype)== "-1" and $dt == ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}$rs = mysql_query($query);
if (!$rs) {
die("Could not query: ".mysql_error());
}
$contents = mysql_fetch_array($rs);
if($total)
{
do
{
$Business_Owner = $contents['Business_Owner'];
$On_Site_Manager = $contents['On_Site_Manager'];
$On_Site_Phone = $contents['On_Site_Phone'];
$Business_Name = $contents['Business_Name'];
$Mailing_Address = $contents['Mailing_Address'];
$Phone_Number = $contents['Phone_Number'];
$Crop_Type = $contents['Crop_Type'];
$Crop_Location = $contents['Crop_Location'];
$Section = $contents['Section'];
$Township = $contents['Township'];
$Rng1 = $contents['Rng1'];
$Direction = $contents['Direction'];
$Quarter = $contents['Quarter'];
$Acreage = $contents['Acreage'];
$County = $contents['County'];
$Date_Of_Entry = $contents['Date_Of_Entry'];
$Contact = $contents['Contact'];
?>
<?php
echo " <tr> <td> ".$contents[0] . " </td> <td>".$contents[1]." </td> <td>".$contents[2]. " </td> <td>".$contents[3]." </td> <td>".$contents[4]." </td> <td>".$contents[5]. " </td> <td>".$contents[6]." </td> <td>".$contents[7]." </td> <td>".$contents[8]." </td> <td>".$contents[9]." </td> <td>".$contents[10]." </td><td>".$contents[11]." </td><td>".$contents[12]." </td><td>".$contents[13]." </td><td>".$contents[14]." </td><td>".$contents[15]." </td><td>".$contents[16]." </td></tr> ";
?>
<?php
}
while($contents = mysql_fetch_array($rs));
$per = $page - 1;
$next = $page + 1;
echo "<center>".$Total." Records.".$perpagenum."Record Each Page, Total ".$Totalpage."Page ";
if($page != 1)
{
echo "<a href='".$_SERVER['PHP_SELF']."'>  First Page  </a>";
echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$per."'>  Prev  </a>";
}
if($page != $Totalpage)
{
echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$next."'>  Next  </a>";
echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$Totalpage."'>  End Page  </a></center>";
}
}
else
{
echo "<center>No message</center>";
}
?>
<th valign="top" class="STYLE6" scope="col"><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<th width="28%" scope="col"><p class="STYLE22">Filter by County</p>
<p>
<select name="county[]" size="15" multiple class="textbox" >
<option value="-1" selected="selected">All Counties</option>
<option value="1">Adams</option>
<option value="2">Antelope</option>
<option value="3">Arthur</option>
<option value="4">Banner</option>
<option value="5">Blaine</option>
<option value="6">Boone</option>
<option value="7">Box Butte</option>
<option value="8">Boyd</option>
<option value="9">Brown</option>
<option value="10">Buffalo</option>
<option value="11">Burt</option>
<option value="12">Butler</option>
<option value="13">Cass</option>
<option value="14">Cedar</option>
<option value="15">Chase</option>
<option value="16">Cherry</option>
<option value="17">Cheyenne</option>
<option value="18">Clay</option>
<option value="19">Colfax</option>
<option value="20">Cuming</option>
</select>
</p></th>
<th width="40%" valign="top" scope="col"><p class="STYLE22">Filter by Crop Type</p>
<p>
<select name="croptype[]" size="6" multiple class="textbox">
<option value="-1" selected="selected">All Crop Types</option>
<option value="2">Fruit or Vegetables</option>
<option value="1">Grapes(vineyards)</option>
<option value="3">Honey</option>
<option value="4">Nursery (ornamental plants, plants for seed, flowers/cut flowers, etc)</option>
<option value="5">Orchard (trees for fruit/nuts)</option>
<option value="6">Organic</option>
<option value="7">Other</option>
</select>
</p></th>
<th width="32%" valign="top" scope="col"><p class="STYLE22">Filter by Date<!--1233 --></p>
<p class="STYLE22">
<label>
<input name="dt" type="date" id="textfield" size="15" class ="textbox">
</label>
</p>
<p align="center" class="STYLE22 style33">If a date is entered, records on or after that date will be returned. <span class="style34">(Format: mm/dd/yyyy e.g. 01/20/2010)</span></p>
<p class="STYLE22"> </p></th>
</tr>
<tr>
<td height="19" colspan="2"> </td>
<! [if IE]>
<input type="text" style="display: none;" disabled="disabled" size="1" /><![sendif]>
</tr>
</table>
<div align="center">
<p class="style25"> To select multiple counties or crop types, hold down the control key and select the items to include in your report. </p>
<p>
<input name="submit" type="submit" value="Submit">
</p>
</div>
</form>
<form action=" " method="get" name="form2" >
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
</form>
webpage.php //后台
<?php$conn=mysql_connect("localhost","","");
if (!$conn) {
die("Could not select db: ".mysql_error());
}
mysql_select_db("vineyard",$conn);
$perpagenum = 10;
$total = mysql_fetch_array(mysql_query("select count(*) from data_query", $conn));
$Total = $total[0];
$Totalpage = ceil($Total/$perpagenum);
if(!isset($_GET['page'])||!intval($_GET['page'])||$_GET['page']>$Totalpage)
{
$page=1;
}
else
{
$page=$_GET['page'];
}
$startnum = ($page-1)*$perpagenum;$county=$_GET['county'];$croptype=$_GET['croptype'];$dt = date('Y-m-d', strtotime($_GET["dt"]));if (implode(",", $county) != "-1" and implode(",", $croptype) != "-1" and $dt != "")
{
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid IN (".implode(",", $county).") AND cropid IN (".implode(",", $croptype).") AND Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) =="-1" and implode(",", $croptype) != "-1" and $dt != ""){
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE cropid in (".implode(",", $croptype).") AND Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) != "-1" and implode(",", $croptype)== "-1" and $dt != ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid in (".implode(",", $county).") AND Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) == "-1" and implode(",", $croptype)== "-1" and $dt != ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE Date_of_Entry >= '$dt' ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) != "-1" and implode(",", $croptype) != "-1" and $dt == "")
{
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid in (".implode(",", $county).") AND cropid in (".implode(",", $croptype).") ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county)=="-1" and implode(",", $croptype) != "-1" and $dt == ""){
$query ="SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE cropid in (".implode(",", $croptype).") ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) != "-1" and implode(",", $croptype)== "-1" and $dt == ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query WHERE ctyid in (".implode(",", $county).") ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}
elseif (implode(",", $county) == "-1" and implode(",", $croptype)== "-1" and $dt == ""){
$query =" SELECT Business_Owner,On_Site_Manager,On_Site_Phone,Business_Name,Mailing_Address,Phone_Number,Crop_Type,Crop_Location,Section,Township,Rng1,Direction,Quarter,Acreage,County,Date_of_Entry,Contact FROM data_query ORDER BY Date_of_Entry limit $startnum,$perpagenum";
}$rs = mysql_query($query);
if (!$rs) {
die("Could not query: ".mysql_error());
}
$contents = mysql_fetch_array($rs);
if($total)
{
do
{
$Business_Owner = $contents['Business_Owner'];
$On_Site_Manager = $contents['On_Site_Manager'];
$On_Site_Phone = $contents['On_Site_Phone'];
$Business_Name = $contents['Business_Name'];
$Mailing_Address = $contents['Mailing_Address'];
$Phone_Number = $contents['Phone_Number'];
$Crop_Type = $contents['Crop_Type'];
$Crop_Location = $contents['Crop_Location'];
$Section = $contents['Section'];
$Township = $contents['Township'];
$Rng1 = $contents['Rng1'];
$Direction = $contents['Direction'];
$Quarter = $contents['Quarter'];
$Acreage = $contents['Acreage'];
$County = $contents['County'];
$Date_Of_Entry = $contents['Date_Of_Entry'];
$Contact = $contents['Contact'];
?>
<?php
echo " <tr> <td> ".$contents[0] . " </td> <td>".$contents[1]." </td> <td>".$contents[2]. " </td> <td>".$contents[3]." </td> <td>".$contents[4]." </td> <td>".$contents[5]. " </td> <td>".$contents[6]." </td> <td>".$contents[7]." </td> <td>".$contents[8]." </td> <td>".$contents[9]." </td> <td>".$contents[10]." </td><td>".$contents[11]." </td><td>".$contents[12]." </td><td>".$contents[13]." </td><td>".$contents[14]." </td><td>".$contents[15]." </td><td>".$contents[16]." </td></tr> ";
?>
<?php
}
while($contents = mysql_fetch_array($rs));
$per = $page - 1;
$next = $page + 1;
echo "<center>".$Total." Records.".$perpagenum."Record Each Page, Total ".$Totalpage."Page ";
if($page != 1)
{
echo "<a href='".$_SERVER['PHP_SELF']."'>  First Page  </a>";
echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$per."'>  Prev  </a>";
}
if($page != $Totalpage)
{
echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$next."'>  Next  </a>";
echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$Totalpage."'>  End Page  </a></center>";
}
}
else
{
echo "<center>No message</center>";
}
?>
implode(',',null) 这样的话,肯定会报错。
echo "<a href='".$_SERVER['PHP_SELF'].'?county='.$county.'&croptype='.$croptype.'&page='.$next."'>  Next  </a>";对于其他的 上一页,最后一页,第一页,都加同样的东西。
最终在地址栏里看到类似这样的地址就对了
http://localhost/webpage.php?county=1&croptype=2&page=2