2007-07-02 05:51:26 +00:00
|
|
|
<?php
|
|
|
|
if ($_POST) {
|
|
|
|
$result = mysql_query($_POST["query"]); //! multiple commands
|
|
|
|
if ($result === true) {
|
|
|
|
$_SESSION["message"] = sprintf(lang('Query executed OK, %d row(s) affected.'), mysql_affected_rows());
|
|
|
|
header("Location: " . $SELF . "sql=" . (SID ? "&" . SID : ""));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
$error = mysql_error();
|
|
|
|
}
|
|
|
|
page_header(lang('SQL command'), (strlen($_GET["db"]) ? "" : "db"));
|
|
|
|
echo "<h2>" . lang('SQL command') . "</h2>\n";
|
|
|
|
|
|
|
|
if ($_POST) {
|
|
|
|
if (!$result) {
|
2007-07-02 16:42:42 +00:00
|
|
|
echo "<p class='error'>" . lang('Error in query') . ": " . htmlspecialchars($error) . "</p>\n";
|
2007-07-02 05:51:26 +00:00
|
|
|
} else {
|
2007-07-02 15:50:35 +00:00
|
|
|
if (!mysql_num_rows($result)) {
|
|
|
|
echo "<p class='message'>" . lang('No rows.') . "</p>\n";
|
|
|
|
} else {
|
|
|
|
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
|
|
|
|
for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
|
|
|
|
if (!$i) {
|
|
|
|
echo "<thead><tr><th>" . implode("</th><th>", array_map('htmlspecialchars', array_keys($row))) . "</th></tr></thead>\n";
|
|
|
|
}
|
|
|
|
echo "<tr>";
|
|
|
|
foreach ($row as $val) {
|
|
|
|
echo "<td>" . (isset($val) ? htmlspecialchars($val) : "<i>NULL</i>") . "</td>";
|
|
|
|
}
|
|
|
|
echo "</tr>\n";
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
2007-07-02 15:50:35 +00:00
|
|
|
echo "</table>\n";
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<form action="" method="post">
|
|
|
|
<p><textarea name="query" rows="20" cols="80"><?php echo htmlspecialchars($_POST["query"]); ?></textarea></p>
|
|
|
|
<p><input type="submit" value="<?php echo lang('Execute'); ?>" /></p>
|
|
|
|
</form>
|