I have a problem when I fetching data from database and row it I Got an error. How To fetch data From database using while and row it.
Fatal error: Call to a member function fetch() on a non-object in
Thanks in advance..
Here is my Code..
<body>
<?php
$id = $_GET['id'];
$iqry = $mysqli->prepare("SELECT itemcode,itemname,brandname,quantity FROM table_inventory WHERE id = ?");
$iqry->bind_param('i', $id);
$iqry->execute();
$iqry->bind_result($itemcode,$itemname,$brandname,$quantity);
$res = $iqry->store_result();
while ($row = $res->fetch()){
$itemcode = $row['itemcode'];
$itemname = $row['itemname'];
$brandname = $row['brandname'];
$quantity = $row['quantity'];
}
?>
<form method="post" name="increasing" action="save.php">
<table>
<tr><td>Itemcode</td><td>:</td><td><input type="text" name="itemcode" required="required" value="<?php echo $itemcode; ?>">/></td></tr>
<tr><td>Itemname</td><td>:</td><td><input type="text" name="itemname" required="required" value="<?php echo $itemname; ?>"/></td></tr>
<tr><td>Brandname</td><td>:</td><td><input type="text" name="brandname" required="required" value="<?php echo $brandname; ?>"/></td></tr>
<tr><td>Quantity</td><td>:</td><td><input type="text" name="quantity" required="required" value="<?php echo $quantity; ?>"/></td></tr>
<tr><td></td><td></td><td><input type="submit" class="myButton" value="Save"/></td></tr>
</table>
</form>
<body>
You seem to be mixing up
mysqli_stmt
andmysqli_result
methods.Try making the following changes:
LIMIT
your resultset to oneStick with the
mysqli_stmt
as you seem to be further along with that