<form>
<select id="name" >
<option></option>
<option>Варна</option>
<option>Бургас</option>
<option>София</option>
<option>Благоевград</option>
</select>
<input type="button" name="RememberMe" onclick="post();">
</form>
<script>function post()
{
//alert("working");
var name = $('#name').val();
var type = $('#type').val();
var raion = $('#raion').val();
$.post('post.php',{postgrad:name,posttype:type,postraion:raion},
function(data){
$('#result').html(data);
});
}
<?php
// the php
<?php
<?php
$name = $_POST['postgrad'];
$type = $_POST['posttype'];
$raion =$_POST['postraion'];
$conn = mysqli_connect('localhost','root','','seacapit_webhelper');
mysqli_set_charset($conn, "utf8");
// find out how many rows are in the table
$sql = "SELECT COUNT(*) FROM products";
$result = mysqli_query($conn,$sql);
$r = mysqli_fetch_row($result);
$numrows = $r[0];
// number of rows to show per page
$rowsperpage = 10;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);
// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage']))
{
// cast var as int
$currentpage = (int) $_GET['currentpage'];
} else {
// default page num
$currentpage = 1;
} // end if
// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
} // end if
// the offset of the list, based on current page
$offset = ($currentpage - 1) * $rowsperpage;
// get the info from the db
$query = "SELECT * FROM products join pic on products.pr_short_name
= pic.pr_short_name where products.search_txt1 = '".$name."'LIMIT
$offset, $rowsperpage";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_assoc($result))
{
$pr_name = $row['pr_name'];
$search_txt1 = $row['search_txt1'];
$search_txt2 = $row['search_txt2'];
$picture = $row['pic_file'];
$search_txt3 = $row['search_txt3'];
echo
"<div class='container' >
<div class='row'>
<div class='col-md-5'>
<img width='100' src='".$picture."'/>
</div>
<div class='col-md-7'>" .$pr_name .
"</div>
<div class='col-md-4' ><p class='text-center'>" .
$search_txt1 . "</p> </div>
<div class='col-md-4' ><p class='text-center'>" .
$search_txt2 . "</p> </div>
<div class='col-md-4' ><p class='text-center'>" .
$search_txt3 . "</p> </div>
</div>
</div> ";
}
// end while
/****** build the pagination links ******/
// range of num links to show
$range = 3;
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='index.php?currentpage=1'><<</a> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <a href='index.php?currentpage=$prevpage'><</a> ";
} // end if
// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) +
1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " [<b>$x</b>] ";
// if not current page...
} else {
// make it a link
echo " <a href='index.php?currentpage=$x'>$x</a> ";
} // end else
} // end if
} // end for
// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <a href='index.php?currentpage=$nextpage'>></a> ";
// echo forward link for lastpage
echo " <a href='index.php?currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/
?>
尝试代码时的问题是: 单击提交时有效,但当我使用分页尝试下一页时,$ _POST ['postname']不再被识别未定义索引:postname 。你能给我一个例子,说明如何使用$ _SESSION或cookie来存储$ _POST。 感谢当时的任何人