How can I do the following in mysqli prepare statement?
$result = mysql_query($sql);
$data = mysql_fetch_assoc($result);
return $data:
That's pretty simple after you've created the connection to mysql somewhere:
The refer to the mysqli object when you need to do a query or do something else.
query($sql);
// fetch the result row.
$data = $result->fetch_assoc();
return $data;
?>
Then at some point (if you have a class, you can write a destructor) you should close the connection to mysql if you won't need it anymore.
kill($mysqli->thread_id);
$mysqli->close();
?>
You can do much more with the result object you have.
So read more about the MySQLi_Result here: