diff --git a/src/QuerySQL.php b/src/QuerySQL.php index aa87cc3eb8..3334f2c72e 100644 --- a/src/QuerySQL.php +++ b/src/QuerySQL.php @@ -35,7 +35,7 @@ } if (isset($_POST['CSV'])) { - ExportQueryResults(); + ExportQueryResults($sSQL, $rsQueryResults); exit; } @@ -50,7 +50,7 @@
- +
@@ -63,17 +63,13 @@ if (isset($_POST['SQL'])) { if (strtolower(mb_substr($sSQL, 0, 6)) === 'select') { - RunFreeQuery(); + RunFreeQuery($sSQL, $rsQueryResults); } } -function ExportQueryResults() +function ExportQueryResults(string $sSQL, &$rsQueryResults) { global $cnInfoCentral; - global $aRowClass; - global $rsQueryResults; - global $sSQL; - global $iQueryID; $sCSVstring = ''; @@ -114,17 +110,15 @@ function ExportQueryResults() } //Display the count of the recordset +if (isset($_POST['SQL'])) { echo '
'; echo mysqli_num_rows($rsQueryResults) . gettext(' record(s) returned'); echo '
'; +} -function RunFreeQuery() +function RunFreeQuery(string $sSQL, &$rsQueryResults) { global $cnInfoCentral; - global $aRowClass; - global $rsQueryResults; - global $sSQL; - global $iQueryID; //Run the SQL $rsQueryResults = RunQuery($sSQL); @@ -174,7 +168,7 @@ function RunFreeQuery() echo ''; echo ''; - if (count($aHiddenFormField) > 0) { // TODO Don't post to CartView.php?> + if ($aHiddenFormField && count($aHiddenFormField) > 0) { // TODO Don't post to CartView.php?>