我每次按点击时都会尝试添加限制但
我的HTML代码是
<div class="media stream load-more">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>" method ='post' name = 'showmore'>
<i class="icon-refresh shaded"></i>
show more...
</a>
</div>
php代码
$showvalue = 2;
if(isset($_POST['showmore'])) {
$showvalue += 1;
}
$feeds = $db->getfeeds($showvalue);
mysql函数
public function getfeeds($showvalue){
$stmt = $this->con->prepare("SELECT id,image,title,status,profilepic,created_at,url FROM news ORDER BY id DESC LIMIT $showvalue");
$stmt->bind_param("s",$showvalue);
$stmt->execute();
$result = $stmt->get_result();
$nrow = array();
while ($r = $result->fetch_assoc()) {
$nrow[] = $r;
}
$frow['news'] = $nrow;
$json = str_replace("\\/", "/",json_encode($frow));
return $json;
}