在PHP中显示数据期间,从第2页开始,Post值不起作用
我想在多个页面中显示大量数据,其中每个页面包含20个数据。我在使用post表单时给出了一些值之后,正在搜索数据。但是post值在显示数据期间对第一页起作用。从第2页开始,post值不起作用。下面是我的行动守则页面在PHP中显示数据期间,从第2页开始,Post值不起作用,php,mysql,Php,Mysql,我想在多个页面中显示大量数据,其中每个页面包含20个数据。我在使用post表单时给出了一些值之后,正在搜索数据。但是post值在显示数据期间对第一页起作用。从第2页开始,post值不起作用。下面是我的行动守则页面 <?php $conn = mysql_connect("localhost","root","1amShaw0n"); mysql_select_db("bkash_plus",$conn); $account_no = $_POST['
<?php
$conn = mysql_connect("localhost","root","1amShaw0n");
mysql_select_db("bkash_plus",$conn);
$account_no = $_POST['account_no'];
$remarks = $_POST['remarks'];
$open_by= $_SESSION['user_name'];
$result = mysql_query("SELECT count(*) as count FROM tickets where created_by='$open_by' and status='Closed' and account_no like '%$account_no%' and remarks like '%$remarks%'");
if(false === $result) {
throw new Exception('Query failed with: ' . mysqli_error());
} else {
while ($row = mysql_fetch_assoc($result)) {
$row_count= $row['count'];
}
}
$page_count = 0;
if (0 === $row_count) {
// maybe show some error since there is nothing in your table
} else {
// determine page_count
$items_per_page = 20;
$page_count = (int)ceil($row_count / $items_per_page);
$page = 1;
if($page > $page_count) {
// error to user, maybe set page to 1
$page = 1;
}
}
// make your LIMIT query here as shown above
// determine page number from $_GET
$page = 1;
if(!empty($_GET['page'])) {
$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
if(false === $page) {
$page = 1;
}
}
// set the number of items to display per page
$items_per_page = 20;
// build query
$offset = ($page - 1) * $items_per_page;
// Collects data from "friends" table
$data = mysql_query("SELECT * FROM bkash_plus.tickets where created_by='$open_by' and status='Closed' and account_no like '%$account_no%' and remarks like '%$remarks%' order by tickets_id desc LIMIT " . $offset . "," . $items_per_page)
or die(mysql_error());
// $result = mysql_query($data) or die ("Error in query: $data. ".mysql_error());
// puts the "friends" info into the $info array
//$info = mysql_fetch_array( $data );
if (mysql_num_rows($data) >= 0) {
echo '<table border="2" width="1030px">
<tr>
<th><center><font color="blue">Ticket_ID</font><center></th>
<th><center><font color="blue">Account No</font><center></th>
<th><center><font color="blue">Created Time</font><center></th>
<th><center><font color="blue">Service Type</font><center></th>
<th><center><font color="blue">Category</font><center></th>
<th><center><font color="blue">Sub_Category</font><center></th>
<th><center><font color="blue">Status</font><center></th>
<th><center><font color="blue">Remarks</font><center></th>
<th><center><font color="blue">Created By</font><center></th>
</tr>';
while($info = mysql_fetch_array($data)){
echo '
<tr>
<td><center><a href=ticket_view_data_front.php?tickets_id='.$info['tickets_id'].'>'.$info['tickets_id'].'</a><center></td>
<td><center>'.$info['account_no'].'<center></td>
<td><center>'.$info['created_time'].'<center></td>
<td><center>'.$info['service_type'].'<center></td>
<td><center>'.$info['category'].'<center></td>
<td><center>'.$info['sub_category'].'<center></td>
<td><center>'.$info['status'].'<center></td>
<td><center>'.$info['remarks'].'<center></td>
<td><center>'.$info['created_by'].'<center></td>
</tr>';
}
echo '</table>';
}
// later when outputting page, you can simply work with $page and $page_count to output links
// for example
for ($i = 1; $i <= $page_count; $i++) {
if ($i === $page) { // this is current page
echo 'Page ' . $i . '';
} else { // show link to other page
echo '>>';
echo '<a href="view_all_ticket_front_closed_search_result.php?page=' . $i . '">Page ' . $i . ' </a>';
}
}
?>
下面是传递POST值的表单页
<form method="post" class="form-horizontal" role="form">
<!-- Account No: <input type="text" name="account_no">
ID: <input type="text" name="id">
<input type="submit" name="submit" value="Check"> -->
<div class="form-group">
<label class="control-label col-sm-2" for="account_no">Account ID:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="account_no" name="account_no" style="height:35px;width:160px">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="remarks">Remarks:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="remarks" name="remarks" style="height:35px;width:160px">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10 ticket">
<input type="submit" class="btn" name="submit" value="View" formaction="view_all_ticket_front_closed_search_result.php">
</div>
</div>
</form>
帐户ID:
评论:
任何人都可以帮我解决这个问题。如何传递$\u POST['account\u no'];?提交页面正在传递两个值。一个是$_POST['account\u no'],另一个是$_POST['Comments'],您的提交页面在哪里?提交页面现在已添加到主问题中…但表单不是每次都提交,只是第一次提交账号等并使用分页。如何传递$_POST['account\u no'];?提交页面传递了两个值。一个是$_POST['account_no'],另一个是$_POST['Comments'],提交页面在哪里?现在主问题中添加了提交页面…但表单不是每次都提交,只是第一次提交账号等并使用分页。
<form method="post" class="form-horizontal" role="form">
<!-- Account No: <input type="text" name="account_no">
ID: <input type="text" name="id">
<input type="submit" name="submit" value="Check"> -->
<div class="form-group">
<label class="control-label col-sm-2" for="account_no">Account ID:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="account_no" name="account_no" style="height:35px;width:160px">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="remarks">Remarks:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="remarks" name="remarks" style="height:35px;width:160px">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10 ticket">
<input type="submit" class="btn" name="submit" value="View" formaction="view_all_ticket_front_closed_search_result.php">
</div>
</div>
</form>