<?php
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($sub4))):
$sub4 = 1;
endif;
$avg = mysql_query("
SELECT AVG(OverallRating) AS AverageRating
FROM Rating_Test
WHERE AirportCode = '" . $sub3 . "'
");
while ($row = mysql_fetch_array($avg)):
$avgRating = $row['AverageRating'];
endwhile;
//Here we count the number of results
//Edit $data to be your query
$data = mysql_query("
SELECT Name
FROM Rating_Test
WHERE AirportCode = '" . $sub3 . "'
ORDER BY SubmissionDate
") or die(mysql_error());
$rows = mysql_num_rows($data);
?>
<h2>Security Profile for <?=$sub3;?></h2>
- Overall Safety Rating: <?=$avgRating;?><br />
- Rated by <?=$rows;?> fliers</br />
<?php
//This is the number of results displayed per page
$page_rows = 10;
//This tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($sub4 <= 1):
$sub4 = 1;
elseif ($sub4 >= $last):
$sub4 = $last;
endif;
$limit = ($sub4 - 1) * 10;
$data_p = mysql_query("
SELECT Name, OverallRating, Comments
FROM Rating_Test
WHERE AirportCode = '" . $sub3 . "'
ORDER BY SubmissionDate
LIMIT " . $limit . ", 10
") or die(mysql_error());
#This is where you display your query results
while($info = mysql_fetch_array($data_p)): ?>
<?=$limit;?>
<?=$sub4;?>
<h3>Review by <?=$info['Name'];?> - rated <?=$sub3;?> +<?=$info['OverallRating'];?></h3>
<?=$info['Comments'];?>
<hr />
<?php
endwhile;
$previous = $sub4-1;
$next = $sub4+1;
?>
<?php if ($sub4 >= 2): ?>
<a href="<?=$root;?>/browse/airport-security-rating/profile/<?=$sub3;?>/1">«First 10</a>
<a href='<?=$root;?>/browse/airport-security-rating/profile/<?=$sub3;?>/<?=$previous;?>'><?=$previous;?></a>
<?php endif; ?>
<strong><?=$sub4;?></strong>
<?php if ($sub4 <= $last): ?>
<a href='<?=$root;?>/browse/airport-security-rating/profile/<?=$sub3;?>/<?=$next;?>'><?=$next;?></a>
<a href='<?=$root;?>/browse/airport-security-rating/profile/<?=$sub3;?>/<?=$last;?>'>Last 10 »</a>
<?php endif; ?>
<!--a href='#'>«Prev 10</a>
<a href='#'>1</a>
<a href='#'>2</a>
<a href='#'>3</a>
<a href='#'>Next 10 »</a-->