Count the destinations.

This commit is contained in:
markjcrane 2015-09-04 23:18:13 -06:00
parent b34f8baeb8
commit 31d727cab5
1 changed files with 74 additions and 74 deletions

View File

@ -50,32 +50,6 @@ else {
$document['title'] = $text['title-destinations'];
require_once "resources/paging.php";
//show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap' valign='top'><b>".$text['header-destinations']."</b></td>\n";
echo " <form method='get' action=''>\n";
echo " <td width='50%' align='right'>\n";
if (permission_exists('destination_all')) {
if ($_GET['showall'] == 'true') {
echo " <input type='hidden' name='showall' value='true'>";
}
else {
echo " <input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='destinations.php?showall=true';\">\n";
}
}
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".$search."'>";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
echo " </td>\n";
echo " </form>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2' valign='top'>\n";
echo " ".$text['description-destinations']."<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
//get total destination count from the database
$sql = "select count(*) as num_rows from v_destinations ";
if ($_GET['showall'] && permission_exists('destination_all')) {
@ -143,10 +117,36 @@ else {
$sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$destination = $prep_statement->fetchAll();
$destinations = $prep_statement->fetchAll();
$destination_count = count($destination);
unset ($prep_statement, $sql);
//show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap' valign='top'><b>".$text['header-destinations']." (".$total_destinations.")</b></td>\n";
echo " <form method='get' action=''>\n";
echo " <td width='50%' align='right'>\n";
if (permission_exists('destination_all')) {
if ($_GET['showall'] == 'true') {
echo " <input type='hidden' name='showall' value='true'>";
}
else {
echo " <input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='destinations.php?showall=true';\">\n";
}
}
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".$search."'>";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
echo " </td>\n";
echo " </form>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2' valign='top'>\n";
echo " ".$text['description-destinations']."<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
@ -171,7 +171,7 @@ else {
echo "</tr>\n";
if ($destination_count > 0) {
foreach($destination as $row) {
foreach($destinations as $row) {
$tr_link = "href='destination_edit.php?id=".$row['destination_uuid']."'";
echo "<tr ".$tr_link.">\n";
if ($_GET['showall'] && permission_exists('destination_all')) {
@ -193,7 +193,7 @@ else {
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $destination, $row_count);
unset($sql, $destinations, $row_count);
} //end if results
echo "<tr>\n";