I want to create a php function that can access the database just by writing a query. for example:
<?php
require"connect.php";
function querymyrow($query) {
global $conn;
return mysqli_fetch_array(mysqli_query($conn, $query));
}
?>
<table border="1">
<?php while ($row = querymyrow("SELECT * FROM product")) { ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['name']; ?></td>
</tr>
<?php } ?>
</table>
The $conn variable is loaded from connect.php so it's not a problem. The problem is that when the program executes, the loop is successful, but only returns the first value from the database until the end of the loop. Does anyone know how to make the correct function in this case?