Remove column or parameter by button

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@260 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2007-07-26 09:18:58 +00:00
parent 6847d89364
commit 1b34824493
3 changed files with 17 additions and 12 deletions

View file

@ -1,5 +1,5 @@
<?php
if ($_POST && !$error && !$_POST["add"]) {
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
if ($_POST["drop"]) {
$query = "DROP TABLE " . idf_escape($_GET["create"]);
$message = lang('Table has been dropped.');
@ -68,11 +68,11 @@ $result->free();
if ($_POST) {
$row = $_POST;
ksort($row["fields"]);
if (!$_POST["add"]) {
echo "<p class='error'>" . lang('Unable to operate table') . ": " . htmlspecialchars($error) . "</p>\n";
$row["fields"] = array_values($row["fields"]);
} else {
$row["fields"] = array_values($row["fields"]);
if ($_POST["add"]) {
array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
} elseif (!$_POST["drop_col"]) {
echo "<p class='error'>" . lang('Unable to operate table') . ": " . htmlspecialchars($error) . "</p>\n";
}
if ($row["auto_increment_col"]) {
$row["fields"][$row["auto_increment_col"] - 1]["auto_increment"] = true;

View file

@ -102,14 +102,14 @@ function edit_fields($fields, $collations, $type = "TABLE") {
?>
<tr>
<?php if ($type == "PROCEDURE") { ?><td><select name="fields[<?php echo $i; ?>][inout]"><?php echo optionlist($inout, $field["inout"]); ?></select></td><?php } ?>
<th><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>" /><input name="fields[<?php echo $i; ?>][field]" value="<?php echo htmlspecialchars($field["field"]); ?>" maxlength="64" /></th>
<th><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>" /><input name="fields[<?php echo $i; ?>][field]" value="<?php echo ($_POST["drop_col"][$i] ? "" : htmlspecialchars($field["field"])); ?>" maxlength="64" /></th>
<?php edit_type("fields[$i]", $field, $collations); ?>
<?php if ($type == "TABLE") { ?>
<td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked="checked"<?php } ?> /></td>
<td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
<td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
<?php } ?>
<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /></td>
<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /> <input type="submit" name="drop_col[<?php echo $i; ?>]" value="<?php echo lang('Remove'); ?>" onclick="return !remove_row(this);" /></td>
</tr>
<?php
if (strlen($field["comment"])) {
@ -148,6 +148,11 @@ function add_row(button) {
added += '0';
return true;
}
function remove_row(button) {
button.form[button.name.replace(/drop_col(.+)/, 'fields$1[field]')].value = '';
button.parentNode.parentNode.style.display = 'none';
return true;
}
function type_change(type) {
var name = type.name.substr(0, type.name.length - 6);
type.form[name + '[collation]'].style.display = (/char|text|enum|set/.test(type.options[type.selectedIndex].text) ? '' : 'none');

View file

@ -1,7 +1,7 @@
<?php
$routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
if ($_POST && !$error && !$_POST["add"]) {
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
if (strlen($_GET["procedure"]) && $mysql->query("DROP $routine " . idf_escape($_GET["procedure"])) && $_POST["drop"]) {
redirect(substr($SELF, 0, -1), lang('Routine has been dropped.'));
}
@ -34,11 +34,11 @@ if ($_POST) {
$row = $_POST;
$row["fields"] = (array) $row["fields"];
ksort($row["fields"]);
if (!$_POST["add"]) {
echo "<p class='error'>" . lang('Unable to operate routine') . ": " . htmlspecialchars($error) . "</p>\n";
$row["fields"] = array_values($row["fields"]);
} else {
$row["fields"] = array_values($row["fields"]);
if ($_POST["add"]) {
array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
} elseif (!$_POST["drop_col"]) {
echo "<p class='error'>" . lang('Unable to operate routine') . ": " . htmlspecialchars($error) . "</p>\n";
}
} elseif (strlen($_GET["procedure"])) {
$row = routine($_GET["procedure"], $routine);