i don't see the next link .. just a number 1 there with the results..
<?php
// how many rows to show per page
$rowsPerPage = 20;
// by default we show first page
$pageNum = 1;
// if $GET['page'] defined, use it as page number
if(isset($GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT * FROM report order by reportID LIMIT $offset, $rowsPerPage";
$result = mysql_query($query)
or die ("couldn't execute query.");
// get the aircraft type
$queryAircraftType = "SELECT distinct AircraftType FROM report";
$resultAircraftType = mysql_query($queryAircraftType) or die ("couldn't execute query.");
$row_num_links_mainAircraftType =mysql_num_rows ($resultAircraftType);
// Get the search variable from URL for AirFrameHours
$AirFrameHours = @$_GET['AirFrameHours'] ;
//trim whitespace from the stored variable
$trimmedAirFrameHours = trim($AirFrameHours);
//separate key-phrases into keywords
$trimmed_arrayAirFrameHours = explode(" ",$trimmedAirFrameHours);
// Get the search variable from URL For Keyword Search
$Keyword = @$_GET['Keyword'] ;
//trim whitespace from the stored variable
$trimmedKeyword = trim($Keyword);
//separate key-phrases into keywords
$trimmed_arrayKeyword = explode(" ",$trimmedKeyword);
// Get the search variable from URL for AirFrameHours
$YearOfOccurence = @$_GET['YearOfOccurence'] ;
//trim whitespace from the stored variable
$trimmedYearOfOccurence = trim($YearOfOccurence);
//separate key-phrases into keywords
$trimmed_arrayYearOfOccurence = explode(" ",$trimmedYearOfOccurence);
// Build SQL Query for Air Frame Hours entered entered
foreach ($trimmed_arrayAirFrameHours as $trimmAirFrameHours){
// EDIT HERE and specify your table and field names for the SQL query
$queryAirFrameHours = "SELECT * FROM report WHERE AirFrameHours LIKE \"%$trimmedAirFrameHours%\"";
// Execute the query to get number of rows that contain search kewords
$numresultsAirFrameHours=mysql_query ($queryAirFrameHours);
$row_num_links_mainAirFrameHours =mysql_num_rows ($numresultsAirFrameHours);
}
// Build SQL Query for each keyword entered
foreach ($trimmed_arrayKeyword as $trimmKeyword){
// EDIT HERE and specify your table and field names for the SQL query
$queryKeyword = "SELECT * FROM report WHERE AirCraftType LIKE \"%$trimmedKeyword%\" OR AircraftTailNo LIKE \"%$trimmedKeyword%\" OR ServicingType LIKE \"%$trimmedKeyword%\" OR DefectInfo LIKE \"%$trimmedKeyword%\" OR Rectifications like \"%$trimmedKeyword%\" OR Comments like \"%$trimmedKeyword%\" OR RelatedDoc like \"%$trimmedKeyword%\"";
$numresultsKeyword =mysql_query ($queryKeyword);
$rowKeyword= mysql_fetch_array ($numresultsKeyword);
$row_num_links_mainKeyword =mysql_num_rows ($numresultsKeyword);
//store record id of every item that contains the keyword in the array we need to do this to avoid display of duplicate search result.
do{
$adid_array[] = $rowKeyword[ 'ReportID' ];
}while( $rowKeyword= mysql_fetch_array($numresultsKeyword));
} //end foreach
//delete duplicate record id's from the array. To do this we will use array_unique function
$tmparr = array_unique($adid_array);
$i=0;
$newarr = isSet($POST['Search']) ? $REQUEST['Search'] : '';
foreach ($tmparr as $v)
{
$newarr .= "'" . $v . "',"; //turn newarr into a comma separated string good for an in clause in a query
}
$newarr = substr($newarr,0,strlen($newarr)-1); //remove the trailing comma
// now you can display the results returned. But first we will display the search form on the top of the page
?>
<?php
if( isset ($resultmsg)){
echo $resultmsg;
exit();
}
else{
echo "<b><font color = \"RED\">Search Results</font></b><br>";
if (!empty($GET['AircraftType']))
{
echo "<b>Aircraft Type: " .$GET['AircraftType']."</b><br>";
}
if (!empty($GET['ServicingType']))
{
echo "<b>ServicingType: " .$GET['ServicingType']."</b><br>";
}
if (!empty($GET['AirFrameHours']))
{
echo "<b>Air Frame Between: " .$GET['AirFrameHours']."hrs to ".$GET['AirFrameHours2']. "hrs</b><br>";
}
if (!empty($GET['YearOfOccurence']))
{
echo "<b>Year Of Occurence: " .$GET['YearOfOccurence']. "</b><br>";
}
if (!empty($GET['Keyword']))
{
echo "<b>Advanced Search Keyword: " .$_GET['Keyword']. "</b><br>";
}
$queryAircraftDisplay = "SELECT * FROM report where reportID != 0";
if (!empty($GET['AircraftType']))
{
$queryAircraftDisplay .= " and aircraftType='".$GET['AircraftType']."' ";
}
if (!empty($GET['ServicingType']))
{
$queryAircraftDisplay .= " and servicingType='".$GET['ServicingType']."' ";
}
if (!empty($GET['AirFrameHours']))
{
$queryAircraftDisplay .= " and AirFrameHours>='".$GET['AirFrameHours']."' and AirFrameHours <= '".$GET['AirFrameHours2']."'";
}
if (!empty($GET['AirFrameHours2']))
{
$queryAircraftDisplay .= " and AirFrameHours>='".$GET['AirFrameHours']."' and AirFrameHours <= '".$GET['AirFrameHours2']."'";
}
if (!empty($GET['YearOfOccurence']))
{
$queryAircraftDisplay .= " and Year(DateOfOccurence) ='".$GET['YearOfOccurence']."' ";
}
if (!empty($beginDate))
{
$queryAircraftDisplay .= " and DateOfOccurence >= '$beginDate' and DateOfOccurence <= '$endDate'";
}
if (!empty($_GET['Keyword']))
{
$queryAircraftDisplay .= " and reportID in ($newarr)";
}
echo $queryAircraftDisplay;
$resultAircraftDisplay = mysql_query($queryAircraftDisplay) or die ("couldn't execute query ".mysql_error());
$num=mysql_numrows($resultAircraftDisplay);
if(($num == 0))
{
echo "<p>Search Error</p><p>Please enter another search...</p>" ;
exit();
}
else
{
//end highlight
$cntr = 1; //counter for the table columns
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#00FFFF>AirCraft Type</td>
<td align=center bgcolor=#00FFFF>AirCraft Tail No.</td>
<td align=center bgcolor=#00FFFF>Airframe Hours</td>
<td align=center bgcolor=#00FFFF>Servicing Type</td>
<td align=center bgcolor=#00FFFF>Date Of Occurence</td>
<td align=center bgcolor=#00FFFF>Defect Info</td>
<td align=center bgcolor=#00FFFF>Rectifications</td>
<td align=center bgcolor=#00FFFF>Comments</td>
<td align=center bgcolor=#00FFFF>Related Documents</td>
</tr><tr>";
//echo "Found " . $num . " of " . $InfoArray["TOTAL_RESULTS"] . " results<BR>";
if($resultAircraftDisplay) // this tests whether there is a result, and prevents error mess in the next step
{
$numrows = mysql_num_rows($resultAircraftDisplay);
}
/*
while ($row = mysql_fetch_array($resultAircraftDisplay))
{
$aircraftType = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '1' ]);
$aircraftTailNo = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '2' ]);
$airFrameHours = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '3' ]);
$servicingType = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '4' ]);
//$date = explode('-', $row['5']);
// $date[0] is the year, [1] is month, [2] is day.
//$actual_date = $date[2].'-'.$date[1].'-'.$date[0];
$actual_date = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '5' ]);
$defectInfo = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '6' ]);
$rectifications = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '7' ]);
$comments = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '8' ]);
$relatedDoc = preg_replace ( "'($Keyword)'si" , "<b>$trimmKeyword</b>" ,$row[ '9' ]);
//if there are 7 cols, write the <tr> tag and reset the counter
if ($cntr == 2)
{
echo "</tr><tr>";
$cntr =1;
}
echo "
<td>$aircraftType </td>
<td>$aircraftTailNo </td>
<td>$airFrameHours </td>
<td>$servicingType </td>
<td>$actual_date </td>
<td>$defectInfo </td>
<td>$rectifications </td>
<td>$comments </td>
<td>$relatedDoc </td>
";
$cntr++; //increment the counter
}//end while */
echo "</tr></table>";
}
}
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"$self?page=$page\">$page</a> ";
}
}
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
// print the navigation link
echo $first . $prev . $nav . $next . $last;