This is what I currently have as far as code for part of my navigation, note this is NOT the categories, it’s the actual ads display part of the code. The object is to display the ads from ad manager using the fopen url while at the same time displaying them in columns with pagination. Could someone help me resolve this problem? I’ve been patiently trying to get this resolved, with absolutely no luck. Another note: Richard, as shown in comments is the developer of the ad manager script, I posted to him as well so I commented accordingly.
To see a live sample of the current output, it’s here: http://reunitemysite.com/richard/sample_page.php
The php pages are listed below
Sample_page.php
[php]
Sample Site Navigation Layout
#aznav {
letter-spacing: 6px;
width: 99%;
background-color: #00CCFF;
border: 1px solid #000;
color: #000;
padding: 5px;
}
#main_content {
width:100%;
background-color:
border: 1px solid #000;
padding: 5px;
position: relative;
}
0-9 | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | Show All Ads
<?php
error_reporting(E_ALL);
ini_set('display_errors','Off');
error_reporting(-1); ?>
<?php
include('columns.php'); ?>
<?php
echo "
";
$f = fopen('http://reunitemysite.com/scripts/amp/show.php?z=1&shape=1&incl=1&ip='.getenv('REMOTE_ADDR').'&url='.urlencode(getenv('HTTP_HOST').getenv('REQUEST_URI')),'r');
echo stripslashes(fread($f,100000));
fclose($f);
include('paginate.php');
echo "
";
?>
Navigation Content Here
[/php]
columns.php
[php]
<?php
$cols=5;
echo "
"; // The container table with $cols columns
do {
echo "";
for($i=1;$i<=$cols;$i++) { // All the rows will have $cols columns even if the records are less than $cols
if($row) {
// Richard, I tried the zone code below, but doesn't work //
?>
|
<?
}
else {
echo " | "; //If there are no more records at the end, add a blank column
}
}
} while($row);
echo "
";
?>[/php]
paginate.php
[php]<!-- Richard, This is the page that I am unsure what to do, as it’s intended to work directly from the database, using sql query. I understand the sql query / database, but not sure how / what to remove to add the zone code from ad manager pro.
ex: <a href="$row['url']">$row['banner']>"; would normally work to display the image / url. -->
Pagination Code
<?php
/* Include your code to connect to DB. */
include('connect.php');
/* Your DB table name */
$tbl_name="amp_ads";
// How many adjacent pages should be shown on each side?
$adjacents = 1;
/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
$query = "SELECT DISTINCT COUNT(*) as num FROM $tbl_name";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
/* Setup vars for query. */
$targetpage = "paginate.php"; //your file name (the name of this file)
$limit = 3; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Get data. */
$sql = "SELECT DISTINCT banner FROM $tbl_name LIMIT $start, $limit";
$result = mysql_query($sql);
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if($lastpage > 1)
{
$pagination .= "";
//previous button
if ($page > 1)
$pagination.= "
previous ";
else
$pagination.= "
previous ";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "
$counter";
else
$pagination.= "
$counter";
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "
$counter ";
else
$pagination.= "
$counter";
}
$pagination.= "
...";
$pagination.= "
$lpm1";
$pagination.= "
$lastpage";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "
1";
$pagination.= "
2";
$pagination.= "
...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "
$counter";
else
$pagination.= "
$counter";
}
$pagination.= "...";
$pagination.= "$lpm1";
$pagination.= "
$lastpage";
}
//close to end; only hide early pages
else
{
$pagination.= "
1";
$pagination.= "
2";
$pagination.= "
...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "
$counter";
else
$pagination.= "
$counter";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "
next ";
else
$pagination.= "
next ";
$pagination.= "
\n";
}
// End of Pagination Script //
?>
<?php
echo $pagination ?>
<?php
// THIS WAS THE OLD COLUMN CODE, BUT I TRIED A NEW ONE AND DISABLED THIS ONE FOR TESTING PURPOSES. THE NEW ONE IS IN THE columns.php FILE INCLUDED //
/*
$result = mysql_query("SELECT * FROM amp_ads") or die(mysql_error());
$numCols = 5;
$numPerCol = ceil(mysql_num_rows($result) / $numCols);
echo "
";
for($col = 1; $col <= $numCols; $col++) {
echo "";
for($row = 0; $row < $numPerCol; $row++) {
$resultRow = mysql_fetch_assoc($result);
if($resultRow == false) {
break;
} */
/* $f = fopen('http://localhost/AdManagerPro/show.php?ad_type=2&incl=1&ip='.getenv('REMOTE_ADDR').'&url='.urlencode(getenv('HTTP_HOST').getenv('REQUEST_URI')),'r');
echo stripslashes(fread($f,100000));
fclose($f); */
/*
}
echo " | ";
}
echo "
";
*/
?>[/php]