Usage Examples
Example 1
This class can be used to display any information from the database whichever way you want it.
You can display 2 COLUMNS BY 2 ROWS as shown in this example.

<?php
// Include all necesay files
require_once("admin/functions/sammysql.inc.php");
require_once("admin/functions/sampaginate.inc.php");
// Instantiate the SamMysql class
$mydat = new SamMysql($dbcon);
// Begin Head
// {Head code ommitted}
?>
<!-- THE MAIN CENTRE TABLE STARTS HERE -->
<center>
<!-- The main body -->
<table border="0" height="100%" cellpadding="0" cellspacing="0" width="95%" align="center">
<tr valign="top"> <!-- MIAN BODY INFOS GOES HERE -->
<td>
<?php
// Let's get the Gallery name
// Sorry, I decided to get my gallery name from database
// depending on which gallery was selected by my visitor
// from the previous page or passed by my page-navigation class
if (isset($_POST['gad']) || $_POST['gad'] !="") {
// This is the first request
$tgal_id = cleana($_POST['gad']);
}
elseif (isset($_GET['gad']) || $_GET['gad'] !="") {
$tgal_id = cleana($_GET['gad']);
}
else {
showmyerror("There is an error with your request, Please try again later");
exit();
}
// NOTE: 'cleana' and 'showmyerror' are my personal defined functions
// So don't worry about them
$gal_name = $mydat->getrow("cid",$tgal_id,"gcategory"); // Using SamMysql Class
// Display the Gallery details in the first Row
?>
<div align="justify" style="padding: 5px">
<table align="left" border="0" width="100%" cellpadding="2" cellspacing="2">
<th class="cat_table_top"> <?php echo $gal_name['title']; ?> </th>
<tr><td>
<?php
// Lets, get things clear
$ptab = "gallerypic"; // the name of the gallery table in database
$wts = "cid"; // the gallery category field in the table
$wtsv = $tgal_id; // the gallery ID for the gallery I want to display
// First of all get the page number of the page to be displayed
// If page navigation has not been clicked, this is the initial or first page
if (!isset($_GET['pgn']) || !isset($_POST['pgn'])){
$p_number = 0;
}
elseif (isset($_GET['pgn'])) {
$p_number = $_GET['pgn'];
}
elseif (isset($_POST['pgn'])) {
$p_number = $_POST['pgn'];
}
// NOTE: We have to define the above in order to use the SamPaginator Class
// Instantiate our class with all necessary details
$mypage = new SamPaginator($mydat,$ptab,"gid","Q",$p_number,2,2,$wts,$wtsv);
// NOTE: Here I am telling the class to display 2 ROWS and 2 COLUMNS per ROW
// making a TOTAL of 4 RECORDS per page.
// Check if there are records
if ($mypage->getTotalRecords() ==0) { // No records
?>
<!-- Dispaly message -->
<div id="se_result"> Sorry, There are no pictures in this Photo-Gallery yet. </div>
<?php
}
else {
// there's result so display result
// let's make things fancyful for the visitor by telling him which page he's looking at
$mypage->showTitle($gal_name['title'],"s_result");// I defined a css ID named 's_result'
// Display record
$mypage->showPhotoGallery("spadd","title","","admin","tdes_a");
}
?>
</td></tr>
<tr> <!-- Display PAGE INDEX here if there are more than one page of results returned. -->
<td align="center">
<?php
$mypage->showPagenumber("photo-gallery.php","","gad",$tgal_id,"","","p_navb","p_nava");
?>
</td></tr>
<tr><td><br> <br> <hr width="80%">
<div align="center"> <a href="gallery.php">Go back to the List of our Photo-Gallery</a> </div>
</td></tr>
</table>
</div>
</td>
</tr>
</table>
See Sample-a.jpg for the output of this script.
You can get various layouts of the gallery by changing the 'Maximum ROWS per Page and the MAXIMUM COLUMNS per ROW when instancing the class. See samples pictures for more examples.
(c) 2008 Olowoyo Samuel