include "conn.php";
include "affiliate.php";
//////////////////////////////////////////////////////////////
// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 30;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
//////////////////////////////////////////////////////////////
$sql = "SELECT id, file, image FROM basic_templates ORDER BY id LIMIT $from, $max_results";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query1.");
// This find the total results for use in the overall page count
$sql2 = "SELECT id, file, image FROM basic_templates ORDER BY id";
$result2 = @mysql_query($sql2,$connection) or die("Couldn't execute query2.");
if (mysql_num_rows($result) > 0 )
{
$hits = mysql_num_rows($result2);//number of results returned
$num_col = 3;//number of columns
$num_col_printed = 0;//number of columns printed
$num_rows = ceil($hits / $num_col);//number of rows needed
$contact_list = "
";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$file = $row['file'];
$image = $row['image'];
// Test Results
$str = strtotime($startdate. "+1 week");
$future = date('Y-m-d', $str);
if ($num_col_printed == $num_col) {
$contact_list .= "
\n\n";
$num_col_printed = 0;
}
// output row from database
$contact_list .= "";
$contact_list .= " ";
$contact_list .= "Template $file
";
$contact_list .= " | ";
// bump up row counter
$num_col_printed++;
} // end while loop
$colstobalance = $num_col - $num_col_printed;
for ($i=1; $i<=$colstobalance; $i++) {
$contact_list .= " | \n";
}
$contact_list .= "
";
///////////////////////////////////////////////
//This is where I will put my next page code.//
///////////////////////////////////////////////
// Figure out the total number of results in DB: but isn't working
//$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM pages"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($hits / $max_results);
$to_display = $from + $max_results;
$from_display = $from + 1;
if ($to_display > $hits) {
$to_display = $hits;
}
// Build Page Number Hyperlinks
$pagelistings = "
| Specials Inquiries Results: $from_display - $to_display of $hits ";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
$pagelistings .= "<<Previous - ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
$pagelistings .= "$i ";
} else {
$pagelistings .= "$i ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
$pagelistings .= " - Next>>";
}
$pagelistings .= " |
";
//////////////////////////
//End of next page code.//
//////////////////////////
}
else
{
$contact_list = "Nothing found under your selections";
}
?>
Basic Templates
echo "$pagelistings"; ?>
echo "$contact_list"; ?>
echo "$pagelistings"; ?>