]> git.joonet.de Git - adminer.git/commitdiff
Use variable instead of literal value
authorJakub Vrana <jakub@vrana.cz>
Fri, 24 May 2013 01:31:48 +0000 (18:31 -0700)
committerJakub Vrana <jakub@vrana.cz>
Fri, 24 May 2013 01:31:48 +0000 (18:31 -0700)
editor/script.inc.php

index f7b7f6448cec2fd4329a920d0d1f2aa0b2d8605f..3ca4b06744ef303ba5e9d1e131d3056446a5b60d 100644 (file)
@@ -3,11 +3,12 @@ if ($_GET["script"] == "kill") {
        $connection->query("KILL " . (+$_POST["kill"]));
 
 } elseif (list($table, $id, $name) = $adminer->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) {
-       $result = $connection->query("SELECT $id, $name FROM " . table($table) . " WHERE " . (ereg('^[0-9]+$', $_GET["value"]) ? "$id = $_GET[value] OR " : "") . "$name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT 11");
-       for ($i=0; $i < 10 && ($row = $result->fetch_row()); $i++) {
+       $limit = 11;
+       $result = $connection->query("SELECT $id, $name FROM " . table($table) . " WHERE " . (ereg('^[0-9]+$', $_GET["value"]) ? "$id = $_GET[value] OR " : "") . "$name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT $limit");
+       for ($i=1; ($row = $result->fetch_row()) && $i < $limit; $i++) {
                echo "<a href='" . h(ME . "edit=" . urlencode($table) . "&where" . urlencode("[" . bracket_escape(idf_unescape($id)) . "]") . "=" . urlencode($row[0])) . "'>" . h($row[1]) . "</a><br>\n";
        }
-       if ($i == 10) {
+       if ($row) {
                echo "...\n";
        }
 }