From 2c381345b49511d881dc1ea68e5ac7abc8cf7045 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 23 May 2013 18:31:48 -0700 Subject: [PATCH] Use variable instead of literal value --- editor/script.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/editor/script.inc.php b/editor/script.inc.php index f7b7f644..3ca4b067 100644 --- a/editor/script.inc.php +++ b/editor/script.inc.php @@ -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 "" . h($row[1]) . "
\n"; } - if ($i == 10) { + if ($row) { echo "...\n"; } }