当 paginating.but 值出现时,检查我的分页 code.my 值是否与表单保持一致
Check my pagination code.my values not sticking with form when paginating.but value are coming
<?php
$per_page=10;
if(isset($_GET['page']))
{
$page = $_GET['page'];
$start_from = ($page-1) * $per_page+1;
$per_page=$start_from+9;
}
else
{
$page=1;
$start_from = ($page-1) * $per_page;
}
$pincode=$_POST['pincode'];
$categorypincode=$_POST['categorypincode'];
$tutorname=$_POST['tutorname'];
$sql = "SELECT tr.*, t.* FROM tinfo t left join tutorregistration tr on tr. tid=t.tsid where pincode LIKE '%$pincode%'";
if($pincode!='' && $categorypincode!='' ){
$sql .= " and classconducted LIKE '%$categorypincode%'";
}
if($pincode!='' && $categorypincode!='' && $tutorname!=''){
$sql .= " and name LIKE '%$tutorname%'";
}
$sql.="LIMIT $start_from, $per_page";
//echo $sql;
$sql = mysql_query($sql);
?>
<form name="f1" action="" method="post">
<input type="text" name="pincode" id="zipsearch" value='<?php echo $pincode;?>' class="buttonlengths" placeholder="Search By pincode,Area,State" required/><br/><br/>
<select name="categorypincode" ize="40" class="buttonlengths" />
<option value="">Sort By Subject</option>
<option value="Class I-V Tuition" <?php if($categorypincode=='Class I-V Tuition') { echo 'selected'; }?>>Class I-V Tuition</option>
<option value="Class VI-VIII Tuition" <?php if($categorypincode=='Class VI-VIII Tuition') { echo 'selected'; }?>>Class VI-VIII Tuition</option> <input type="text" name="tutorname" value="<?php echo $tutorname; ?>" class="buttonlengths" placeholder="Search By Tutor Name"/><br/><br/>
<input type="submit" id="tbx2" name="submitpincode" value="Search"/>
</form>
<?php
$query = "SELECT tr.*, t.* FROM tinfo t left join tutorregistration tr on tr. tid=t.tsid";
$result = mysql_query($query);
// Count the total records
$total_records = mysql_num_rows($result);
echo "showing".$start_from."to".$per_page."of".$total_records."<Br/>";
while($row=mysql_fetch_array($sql))
{
$v=$row['tinfoid'];
?>
<?php echo '<a href="#" id="downloadpdf" ><span class="details" style="cursor:none";>Name:</span>'.$row['name'].'</a>';?><Br/><Br/>
<?php echo '<span class="details">Years of Experience:</span>'.$row['texper'];?><Br/><Br/>
<?php
}
$total_records = mysql_num_rows($result);
$total_pages = ceil($total_records /10);
echo "<center><a href='itoriginal.php?page=1'>".'First Page'."</a> ";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='itoriginal.php?page=".$i."'>".$i."</a> ";
};
echo "<a href='itoriginal.php?page=$total_pages'>".'Last Page'."</a></center> ";
?>
我实现了这样的分页 我像这样输出第一页:显示 1 到 10 条记录,共 200 条记录,第二页:它应该显示 11 到 20 条记录,共 200 条,我对此很满意,请交叉检查什么我做了,只是我发现了我自己的想法,etc.Now 当我分页时,假设如果我点击第 3 页 link 值不符合表格 fields.kindly 交叉检查并告诉我在哪里设置表单字段中的条件。
修改代码如下
$page=1;
$per_page=10;
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
$start_from = ($page-1) * $per_page;
在 LIMIT 之前添加 space。
$sql.=" LIMIT $start_from, $per_page";
使用 post 数据 pincode
设置分页 url
echo "<center><a href='itoriginal.php?page=1&pincode=$pincode&categorypincode=$categorypincode' >".'First Page'."</a> ";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='test.php?page=".$i."&pincode=$pincode&categorypincode=$categorypincode'>".$i."</a> ";
};
echo "<a href='itoriginal.php?page=$total_pages&pincode=$pincode&categorypincode=$categorypincode'>".'Last Page'."</a></center> ";
获取密码如下,
$pincode=$_REQUEST['pincode'];
<?php
$per_page=10;
if(isset($_GET['page']))
{
$page = $_GET['page'];
$start_from = ($page-1) * $per_page+1;
$per_page=$start_from+9;
}
else
{
$page=1;
$start_from = ($page-1) * $per_page;
}
$pincode=$_POST['pincode'];
$categorypincode=$_POST['categorypincode'];
$tutorname=$_POST['tutorname'];
$sql = "SELECT tr.*, t.* FROM tinfo t left join tutorregistration tr on tr. tid=t.tsid where pincode LIKE '%$pincode%'";
if($pincode!='' && $categorypincode!='' ){
$sql .= " and classconducted LIKE '%$categorypincode%'";
}
if($pincode!='' && $categorypincode!='' && $tutorname!=''){
$sql .= " and name LIKE '%$tutorname%'";
}
$sql.="LIMIT $start_from, $per_page";
//echo $sql;
$sql = mysql_query($sql);
?>
<form name="f1" action="" method="post">
<input type="text" name="pincode" id="zipsearch" value='<?php echo $pincode;?>' class="buttonlengths" placeholder="Search By pincode,Area,State" required/><br/><br/>
<select name="categorypincode" ize="40" class="buttonlengths" />
<option value="">Sort By Subject</option>
<option value="Class I-V Tuition" <?php if($categorypincode=='Class I-V Tuition') { echo 'selected'; }?>>Class I-V Tuition</option>
<option value="Class VI-VIII Tuition" <?php if($categorypincode=='Class VI-VIII Tuition') { echo 'selected'; }?>>Class VI-VIII Tuition</option> <input type="text" name="tutorname" value="<?php echo $tutorname; ?>" class="buttonlengths" placeholder="Search By Tutor Name"/><br/><br/>
<input type="submit" id="tbx2" name="submitpincode" value="Search"/>
</form>
<?php
$query = "SELECT tr.*, t.* FROM tinfo t left join tutorregistration tr on tr. tid=t.tsid";
$result = mysql_query($query);
// Count the total records
$total_records = mysql_num_rows($result);
echo "showing".$start_from."to".$per_page."of".$total_records."<Br/>";
while($row=mysql_fetch_array($sql))
{
$v=$row['tinfoid'];
?>
<?php echo '<a href="#" id="downloadpdf" ><span class="details" style="cursor:none";>Name:</span>'.$row['name'].'</a>';?><Br/><Br/>
<?php echo '<span class="details">Years of Experience:</span>'.$row['texper'];?><Br/><Br/>
<?php
}
$total_records = mysql_num_rows($result);
$total_pages = ceil($total_records /10);
echo "<center><a href='itoriginal.php?page=1'>".'First Page'."</a> ";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='itoriginal.php?page=".$i."'>".$i."</a> ";
};
echo "<a href='itoriginal.php?page=$total_pages'>".'Last Page'."</a></center> ";
?>
我实现了这样的分页 我像这样输出第一页:显示 1 到 10 条记录,共 200 条记录,第二页:它应该显示 11 到 20 条记录,共 200 条,我对此很满意,请交叉检查什么我做了,只是我发现了我自己的想法,etc.Now 当我分页时,假设如果我点击第 3 页 link 值不符合表格 fields.kindly 交叉检查并告诉我在哪里设置表单字段中的条件。
修改代码如下
$page=1;
$per_page=10;
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
$start_from = ($page-1) * $per_page;
在 LIMIT 之前添加 space。
$sql.=" LIMIT $start_from, $per_page";
使用 post 数据 pincode
设置分页 urlecho "<center><a href='itoriginal.php?page=1&pincode=$pincode&categorypincode=$categorypincode' >".'First Page'."</a> ";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='test.php?page=".$i."&pincode=$pincode&categorypincode=$categorypincode'>".$i."</a> ";
};
echo "<a href='itoriginal.php?page=$total_pages&pincode=$pincode&categorypincode=$categorypincode'>".'Last Page'."</a></center> ";
获取密码如下,
$pincode=$_REQUEST['pincode'];