我不斷收到:查詢不起作用。介意看看它?
警告:mysqli_fetch_assoc()預計參數1被mysqli_result,布爾在
給我列在下面討論的SQL,我想知道什麼即時做錯了( $狀態是一個字符串,只是說:「表單提交)
$sql= "SELECT * FROM `veggie` ORDER BY `buy_date` desc LIMIT 20 OFFSET 0 WHERE `status` = '$status' ";
編輯:可以做線50和84
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/system/init.php';
if (!is_logged_in()) {
login_error_redirect();
}
include 'includes/head.php';
include 'includes/navigation.php';
$page='';
$status = "Form Submitted";
if (!isset($_GET['page'])){
$sql= "SELECT * FROM `veggie` ORDER BY `buy_date` desc LIMIT 20 OFFSET 0 WHERE `status` = '$status' ";
}
if(isset($_GET['page'])){
$page = $_GET['page'];
$offset = 20 * $page;
$sql= "SELECT * FROM veggie ORDER BY buy_date desc LIMIT 20 OFFSET $offset WHERE `status` = '$status' ";
}
$result = $db->query($sql);
$p = $page;
?>
<h2 class="text-center">Veggie Crate Forms</h2><hr>
<table class= "table table-bordered table-striped table-auto">
<thead>
<th class="info">Full_Name</th>
<th class="info">email</th>
<th class="success">crate</th>
<th class="active"># people</th>
<th class="active">Products</th>
<th class="active">Bulk Items</th>
<th class="active">Interests</th>
<th class="active">How did you find us?</th>
<th class="active">Are you ready?</th>
<!-- <th class="danger">Delete</th> -->
</thead>
<tbody>
<?php
?>
<?php while($archived = mysqli_fetch_assoc($result)) : ?>
<?php
$full_name = $archived['first'].' '.$archived['last'];
?>
<tr>
<td><?=$full_name?></td>
<td><?=$archived['email']?></td>
<td><?=$archived['crate']?></td>
<td><?=$archived['people']?></td>
<td><?=$archived['bulk']?></td>
<td><?=$archived['class']?></td>
<td><?=$archived['how']?></td>
<td><?=$archived['ready']?></td>
<!-- <td><a href="archived.php?delete=<?=$archived['id']?>"><span class="glyphicon glyphicon-minus">Delete</span></a></td> -->
</tr>
<?php endwhile; ?>
</tbody>
</table>
<div id="decrease" style="" class="">
<?php if ($page > 0): ?>
<form class="form" action="whf.php?page=<?=--$p?> " method="post">
<input type="submit" name="name" value="<--">
<?php endif; ?>
</div>
<div id="increase" class="">
<?php $countr = mysqli_num_rows($result);
if($countr == 10){
if ($page == '' || $page < 1): ?>
<form class="form" action="whf.php?page=1 " method="post">
<input type="submit" name="name" value="-->">
<?php endif; ?>
<?php
if ($page < $countr && $page != '' && $page != 0): ?>
<form class="form" action="whf.php?page=<?=++$p?> " method="post">
<input type="submit" name="name" value="-->">
<?php endif;
} ?>
</div>
<?php include 'includes/footer.php'; ?>
請發表您的其他代碼,特別是產生該警告的行 – Pevara
您是否已經迴應了您的sql並直接在mysql上運行它?我將確保它在針對mysql運行時確實返回了一些結果 – xJoshWalker
在查詢中有語法錯誤 –