<?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.');
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;
?>
<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"])) {
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');
<?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.'));
}
$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);