git revert -n <sha>
如何加入这两个$ stmt?
$per_page = 6;
if (isset($_GET["page"]))
$page = $_GET["page"];
else
$page = 1;
$start_from = ($page-1) * $per_page;
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM stock LIMIT $start_from, $per_page");"
我收到错误:
错误:SQLSTATE [42000]:语法错误或访问冲突:1064
答案 0 :(得分:1)
我会这样做:
$id = $_GET['id'];
$stmt = $conn->prepare("SELECT * FROM stock WHERE id= '$id' LIMIT $start_from, $per_page");
$stmt->execute();