When I try to change the code from the first block to second block, I get an error message saying it returned false. This is always how I use prepared statements for all the other methods (delete, insert, like). I believe the while loop is causing the issue.
This code below code works (but probably not SQLI injection proof):
$id=$_GET['edit'];
$result = mysqli_query($con, "SELECT * FROM employees WHERE id=$id");
This code below gets an error message basically saying that it returned false:
$result = $con->prepare("SELECT * FROM employees WHERE id=?");
$result->bind_param('i', $_GET['edit']);
$result->execute();
while($row = mysqli_fetch_assoc($result)) {
$id= $row['id'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$position = $row['position'];
This code below I used for a search bar and it works 100%. However, for update it gets the following error message:
Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_array():
while ($row = $result->fetch_array(MYSQLI_NUM))