Created
March 18, 2016 21:29
-
-
Save kimonostereo/5708414b38fe2053a922 to your computer and use it in GitHub Desktop.
This works with PHP Pagination code. Page uses itself as the actual form and the return values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('log_errors',0); | |
ini_set('display_errors',0); | |
?> | |
<html> | |
<head> | |
<title>Directory Display</title> | |
</head> | |
<body> | |
<?php include ("dbaccess.php"); ?> | |
<?php include ("PHPagination.php") ?> | |
<h1>Search Results</h1> | |
<h2>Directory</h2> | |
<hr /> | |
<form action="display.php" method="get" accept-charset="utf-8"> | |
<?php | |
// Create the actual search variable | |
$search = $_GET["search"]; | |
if(empty($search)) { // add search criteria | |
echo '<label>Quick Search:</label> <input type="text" name="search" value="" id="search" /> '; | |
} else { // keep search value | |
echo '<label>Quick Search:</label> <input type="text" name="search" value="'.$search.'" id="search" /> '; | |
} | |
?> | |
<input type="submit" value="Search"> | |
</form> | |
<?php | |
// Check if pCurrent is set | |
if (!isset($_GET['p'])) {$pCurrent = 0;} else {$pCurrent = $_GET['p'];} | |
// PHPagination function | |
$aLeft = 'display.php?p='; | |
$aRight = '&search='.$search ; | |
// PHPagination Optional arguments | |
$sMultiplier = 10; | |
$sArrows = FALSE; | |
// Start finding stuff | |
$find = $fm->newFindCommand("Layout #1"); | |
$find->addFindCriterion("fullname", $search); | |
//$find->addFindCriterion("firstname", $search); | |
//$find->setLogicalOperator(FILEMAKER_FIND_OR); | |
$find->addSortRule("lastname", 1); | |
$find->addSortRule("firstname", 2); | |
$find->setRange($pCurrent, $sMultiplier); | |
$result = $find->execute(); | |
if(!$error) { | |
$records = $result->getRecords(); | |
$pEnd = $result->getFoundSetCount(); | |
$fetchcount = $result->getFetchCount(); | |
} | |
?> | |
<table> | |
<tbody> | |
<?php | |
// Loop through all the records | |
if(empty($error)) { | |
foreach($records as $record){ | |
?> | |
<tr> | |
<td> | |
<?php echo $record->getField ('firstname'); ?> | |
</td> | |
<td> | |
<?php echo $record->getField ('lastname'); ?> | |
</td> | |
<td> | |
<?php echo $record->getField ('phone'); ?> | |
</td> | |
<td> | |
<?php echo $record->getField ('email'); ?> | |
</td> | |
<td> | |
</td> | |
</tr> | |
</tbody> | |
<?php | |
} | |
} else { | |
echo "<p>No records found</p>"; | |
} | |
?> | |
</table> | |
<?php | |
// Add in the PHPagination code | |
echo PHPagination($pCurrent, $pEnd, $aLeft, $aRight, $sMultiplier, $sArrows); | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment