Skip to content

Commit

Permalink
initialize $sRowClass so AlternateRowStyle works (#7158)
Browse files Browse the repository at this point in the history
# Description & Issue number it closes 
<!-- Please include a summary of the changes and the related issue.
Please also include relevant motivation and context. -->

initialize `$sRowClass` so `AlternateRowStyle` works

from Gitter:

>In Data/Reports -> Query Menu, if you run for example a Birthdays
query, which should return a person, the results are not shown and the
page seems unfinished (also menus on the left or icons on the right top
do not expand if you click on them if this happens). This does not
happen when you run a query which do not return any result.
You can check this issue by running the Demo session, add some person
with a birth date, and then try the Birthdays query which should return
that person.
There is actually and error in log file for this issue: `Uncaught
TypeError: AlternateRowStyle(): Argument #1 ($sCurrentStyle) must be of
type string, null given`
I have not tried all the queries on the Query Menu page, but it seems
other queries do the same.
  • Loading branch information
DAcodedBEAT authored Sep 21, 2024
2 parents 4ee4d72 + 693662b commit 1a1607e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/QuerySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function ExportQueryResults(string $sSQL, &$rsQueryResults)

$sCSVstring .= "\n";

//Loop through the recordsert
//Loop through the recordset
while ($aRow = mysqli_fetch_array($rsQueryResults)) {
//Loop through the fields and write each one
for ($iCount = 0; $iCount < mysqli_num_fields($rsQueryResults); $iCount++) {
Expand Down Expand Up @@ -132,7 +132,7 @@ function RunFreeQuery(string $sSQL, &$rsQueryResults)

echo '</tr>';

//Loop through the recordsert
//Loop through the recordset
while ($aRow = mysqli_fetch_array($rsQueryResults)) {
$sRowClass = AlternateRowStyle($sRowClass);

Expand All @@ -146,7 +146,7 @@ function RunFreeQuery(string $sSQL, &$rsQueryResults)
$aHiddenFormField[] = $aRow[$iCount];
} else { //...otherwise just render the field
//Write the actual value of this row
echo '<td align="center">' . $aRow[$iCount] . '</td>';
echo '<td align="center">' . htmlspecialchars($aRow[$iCount]) . '</td>';
}
}
echo '</tr>';
Expand Down
3 changes: 2 additions & 1 deletion src/QueryView.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ function DoQuery()
<?php
$aAddToCartIDs = [];

$sRowClass = 'RowColorA';
while ($aRow = mysqli_fetch_array($rsQueryResults)) {
// Alternate the background color of the row
$sRowClass = AlternateRowStyle($sRowClass);
Expand All @@ -229,7 +230,7 @@ function DoQuery()
} else {
// ...otherwise just render the field
// Write the actual value of this row
echo '<td>' . $aRow[$iCount] . '</td>';
echo '<td>' . htmlspecialchars($aRow[$iCount]) . '</td>';
}
}

Expand Down

0 comments on commit 1a1607e

Please sign in to comment.