PCHomepage
Programmer
I have a page with several forms but one is causing me no end of grief! I can't seem to figure out how to make it not show when nothing has been submitted to it. If one of the other forms is submitted, it triggers this one but without any specific values having been sent, it shows all entries. The query is built dynamically from many form options so it's impractical to do a conditional for each one and I'm not totally sure how the query itself can be reworked to show no results without breaking it.
Here is what I have; any ideas?
Here is what I have; any ideas?
Code:
$FullQuery = $BaseQuery . $Where . $OrderBy;
if ($_POST) {
if ($result = $mysqli->query($FullQuery)) {
$count = $result->num_rows;
if ($count > 0) {
$SelectFile = "<form class=\"SearchResults\" name=\"SearchForm\" method=\"POST\" action=\"dcs_searchresults.php\">\n";
$SelectFile .= "Devices found:<br>\n";
$Query = $FullQuery;
$i = 0;
while ($row = $result->fetch_row()) {
if ($row[3] && !$row[4]) {$Updated = date("M d Y g:i:s A", $row[3]);};
if ($row[4]) {$Updated = date("M d Y at H:i:s", $row[4]);}
$Shortname = basename($row[0], ".csv");
$SelectFile .= "<input name=\"ID[]\" type=\"checkbox\" value=\"$row[1]\">$Shortname ($Updated)<br>\n";
$i++;
}
$result->close();
echo "<input type=\"submit\" name=\"Process Selected Files\" value=\"Process\">\n";
echo "</form>\n\n";
} elseif ($count == 0) {
$SelectFile = "<div class=\"Message\">\n";
$SelectFile .= "Sorry, no files were found. Please select or enter other parameters.\n";
$SelectFile .= "</div>\n\n";
}
echo $SelectFile;
}
}