收到警告mysqli_fetch_assoc()期望参数1为mysqli_result,给定数组

时间:2019-03-17 06:57:13

标签: php

我收到警告消息:mysqli_fetch_assoc()期望参数1为mysqli_result,给出数组

    $item_query = "SELECT * FROM donation JOIN verification on donation.id=verification.donation_id JOIN user on user.id=donation.user_id";
    $result = mysqli_query($con, $item_query) ;

if (mysqli_num_rows($result)>0) {

    while ($r = mysqli_fetch_assoc($result)) {
        $result = array(
            'email' => $r['email']
        );
        array_push($all, $result);
    }
    echo json_encode($all);
}
     else {
        echo '{"success":0}';
    }

1 个答案:

答案 0 :(得分:0)

尝试将您的代码更改为:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
	<table class="table table-bordered">
		<thead>
			<tr>
				<td>Sl.No</td>
				<td>Product</td>
				<td>Buy Price</td>
				<td>Tax</td>
				<td>Sell Price</td>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>1</td>
				<td>
					<select id="prod-1">
						<option>Select</option>
						<option value="1">Product 1</option>
						<option value="2">Product 2</option>
						<option value="3">Product 3</option>
						<option value="4">Product 4</option>
					</select>
				</td>
				<td>
					<input type="text" id="txtBuyPrice-1" value="" placeholder="Buy Price" onblur="calculateSellPrice(1);" />
				</td>
				<td>
					<input type="text" id="txtTax-1" value="" placeholder="Tax" onblur="calculateSellPrice(1);" />
				</td>
				<td>
					<input type="text" id="txtSellPrice-1" value="" placeholder="Sell Price" disabled />
				</td>
			</tr>
			<tr>
				<td>2</td>
				<td>
					<select id="prod-2">
						<option>Select</option>
						<option value="1">Product 1</option>
						<option value="2">Product 2</option>
						<option value="3">Product 3</option>
						<option value="4">Product 4</option>
					</select>
				</td>
				<td>
					<input type="text" id="txtBuyPrice-2" value="" placeholder="Buy Price" onblur="calculateSellPrice(2);" />
				</td>
				<td>
					<input type="text" id="txtTax-2" value="" placeholder="Tax" onblur="calculateSellPrice(2);" />
				</td>
				<td>
					<input type="text" id="txtSellPrice-2" value="" placeholder="Sell Price" disabled />
				</td>
			</tr>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="5" style="text-align: right;">
					<label id="lblGrandTotal">Grand Total: 0</label>
				</td>
			</tr>
		</tfoot>
	</table>
	
</body>
</html>