diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index a193a5d5..f49744a1 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -8,10 +8,16 @@ foreach ($fields as $name => $field) { } } if ($_POST && !$error && !isset($_GET["select"])) { - $location = ($_POST["insert"] // continue edit or insert - ? $_SERVER["REQUEST_URI"] - : ME . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]) //! append &set converted to &where - ); + $location = $_SERVER["REQUEST_URI"]; // continue edit or insert + if (!$_POST["insert"]) { + $location = ME . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]); + $i = 0; // append &set converted to &where + foreach ((array) $_GET["set"] as $key => $val) { + if ($val == $_POST["fields"][$key]) { + $location .= where_link($i++, bracket_escape($key, "back"), $val); + } + } + } $set = array(); foreach ($fields as $name => $field) { $val = process_input($field); diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 4859e4f2..fd499834 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -94,7 +94,7 @@ function where_check($val) { } function where_link($i, $column, $value) { - return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($value); + return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($value); } function redirect($location, $message = null) { diff --git a/adminer/select.inc.php b/adminer/select.inc.php index b0e82632..068e3eb8 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -220,14 +220,15 @@ if (!$columns) { $val = nl2br(h($val)); } - // link related items - foreach ((array) $foreign_keys[$key] as $foreign_key) { - if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) { - foreach ($foreign_key["source"] as $i => $source) { - $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]); + if (!$link) { // link related items + foreach ((array) $foreign_keys[$key] as $foreign_key) { + if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) { + foreach ($foreign_key["source"] as $i => $source) { + $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]); + } + $link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link); // InnoDB supports non-UNIQUE keys + break; } - $link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"])) . $link; // InnoDB supports non-UNIQUE keys - break; } } } @@ -242,13 +243,12 @@ if (!$columns) { echo ""; foreach ($table_names as $table => $name) { foreach ($backward_keys[$table] as $columns) { - echo " $name"; + echo " $name"; } } }