I am having trouble creating a general MySQLi query box, where the results, regardless of the type of query, are output in another textarea - similar to the textarea from the SQL tab in PHPMyAdmin.
For example:
- I would like to display a textarea on my page.
- User enters ANY MySQL code, whether it be SELECT, UPDATE, DELETE, etc.
- Results are displayed in a results textarea, for example, if they enter a SELECT query, they get the results, if they enter a DELETE, they will get a # of deletions.
- Functions just like the SQL tab of PHPMyAdmin.
Is there a simplified way to do this? Or do I need to detect their query, and return results depending on an algorithm that I have to write (which I can do, I'm just trying to avoid all that coding).
This is what I've tried last:
$mysqli = new mysqli($host, $username, $pw, $dbname);
if ($mysqli->connect_errno) {
echo "BAD CONNECTION!";
} else {
$result = $mysqli->query($query);
print_r($result);
mysqli_free_result($result);
}
$mysqli->close();
I also tried:
echo $result
Thanks!