Website Navigation help...

Hi,

I would like to create a website navigation. The output similar to tis page: http://fwgallery.fastw3b.net/galleries.html

My site will be used for banner ads, so the code to get the images (ads) will be generated from my ad manager php script, which will be pasted into the page where the images in the gallery would be. Can someone help me get the foundation for this? I am a total beginner at php coding.

Note: The category images will not come from the
I have a database for the categories already created. Builit on a parent / child realtionship.

I appreciate the help in advnace!
Brian

Could you please explain the database structure?

Also, how are the gallery page(s) displayed? Do you have one central menu that links to other pages? Are these pages static HTML or generated by PHP/

Hi,

I have a database, and it is working, but I don’t know if the parent child relation is correct for this layout. I have some sample code that someone else help me do for a different layout than the one I am asking for now. By parent child relation, I mean the database would have columns of parentid, catid, name. If the parent id was 0 it would be a category, otherwise it would be a subcategory.

As far as the menu. I don’t have / want a menu just the navigation like on the site i posted. As in You have the main div container, and the categories are displayed, which then link to the subcategories, then to the ads (images)

Thanks again!
Brian

Ok, I have been ableto get some php code to work, but, I ran into a big problem and it has to do with the ad manager code generator to display the banners. I would go to my ad manager admin page and generate banner display code for a zone which would look something like this

[php]$f = fopen(‘http://localhost/AdManagerPro/show.php?z=2&incl=1&ip=’.getenv(‘REMOTE_ADDR’).’&url=’.urlencode(getenv(‘HTTP_HOST’).getenv(‘REQUEST_URI’)),'r’);
echo stripslashes(fread($f,100000));
fclose($f);[/php]

The output from that code displays the ads randomly and some ads don’t get displayed I tried numerous admin settings in my ad manager and no good…same results. And ideas how to get all ads to display?

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 echo $f ?>" />  
 
"; ?>[/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 ""; } 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 "
"; */ ?>[/php]

If there’s a problem with your ad manager, then there’s really nothing I can help you with on that. Also, which part of the ad code controls which banner is shown? If it gives a random one, then there’s no point into putting them in pages or categories - you’ll just get random ones in each.

Hi,

The part that shows the banners is in the sample_page.php (first bit of code block) near the bottom. It’s where you see the fopen part (I left a gap where that entire code is, 5 lines I believe). It displays the ads randomly, but only for that zone, another words, if someone were to put ads into that zone, just those ads would rotate, meaning each ad would still exist in that category, but not in the same spot / position, it’s based on the clicks / impressions / advantage that is what I meant about random. I have a copy of the script I can give you to test if you need, but it would only work on localhost.

In columns.php you use the variable $f (echoing it), yet this variable is a file resource:

[php]

<?php echo $f ?>" />[/php]
[php]$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’);[/php]

I really don’t understand what you’re trying to do. Are you trying to display only adverts in a certain category (then have pagination for items in that category)? Or are you trying to have one page per category?

Hi,

Sorry for the late reply, I just got in from work…

Basically, what I am trying to achieve is to create a layout just like what is on this gallery page:

http://fwgallery.fastw3b.net/en/galleries.html

the idea I am trying to get is like what is found on this site:

http://fwgallery.fastw3b.net/en/galleries.html

Notice when you click on the category Animals there are subcategories such as cats, dogs, birds, etc…etc… and you see the pagination at the bottom of the category & subcategory & image pages? That’s how I want to do my navigation, only with banner ads, where you will be able to choose from a drop down menu (like on that site) to choose the size banner (ad) in that particular category to show that zones ads, also not to forget the option to choose how many categories or subcategories or images to display per page like shown on that gallery page.

Thank you
-Brian

Ahh that makes much more sense! Where do you tell the ad script which category to take the adds from?

It’s in the admin page, where I generate that fopen url that I posted in another message. That code is in the ad manager pro admin page. If you want access to it let me know, and I will give you administrator privileges if needed.

That shouldn’t be needed. Can you provide examples of the fopen file for different categories, e.g. for category with ID of 1 and ID of 2.

The generated code from the ad manager does not work in the way you specify, it only works with the fopen url structure or a javascript version of basically the same kind of url. I can give you a copy of my database sql file if you want it. Do you want it?

My mistake…I didn’t understand you message at first.

Here’s some sample categories by zone url:

Zone 1:

[php]$f = fopen(‘http://localhost/AdManagerPro/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);
[/php]

Zone 2:

[php]$f = fopen(‘http://localhost/AdManagerPro/show.php?z=2&incl=1&ip=’.getenv(‘REMOTE_ADDR’).’&url=’.urlencode(getenv(‘HTTP_HOST’).getenv(‘REQUEST_URI’)),'r’);
echo stripslashes(fread($f,100000));
fclose($f);[/php]

Zone 3:

[php]$f = fopen(‘http://localhost/AdManagerPro/show.php?z=3&incl=1&ip=’.getenv(‘REMOTE_ADDR’).’&url=’.urlencode(getenv(‘HTTP_HOST’).getenv(‘REQUEST_URI’)),'r’);
echo stripslashes(fread($f,100000));
fclose($f);
[/php]

Note: These zones are to display only one ad at a time. I want to display several.

Here’s code for zone 1 again, but with 10 banners: Note is there a way to make it so that the following could be for any amount of ads instead of 10 without having to change it first in the admin area then regenerate the code?

[php]$f = fopen(‘http://localhost/AdManagerPro/show.php?z=1&shape=2&incl=1&ip=’.getenv(‘REMOTE_ADDR’).’&url=’.urlencode(getenv(‘HTTP_HOST’).getenv(‘REQUEST_URI’)),'r’);
echo stripslashes(fread($f,100000));
fclose($f);[/php]

Thanks again!
-Brian

It appears that the get variable ‘z’ is changed for zone - which we could easily do. On the other hand, the ‘shape’ variable is used for the number of items yet it does not give us how many to output - I think it probably just references a ad script setting - e.g. number 2 outputs 5 banners, number 3 outputs 2 long banners etc.

Do you want me to send you a copy of the ad manager script so you can look through the files?

-brian

Hi Jsherz,

Have you had a chance to work on the navigation?

-Brian

So, in theory, you want to have the navigation set into zones - the user chooses a zone and then views adverts for that zone? Do you still want pagination?

Hi Jsherz,

Yes, and yes. The pagination because I would like to have the ability to add more categories over a given amount of time, also I wouild like to put the drop down menus too so the amount of categories / subcategories and banners can be adjusted for a given zone.

Thank you.
Brian

Also from the page page that displays the actual ads, I would like for there to be a default ad size to be displayed on that page (say 120 x 240 px) and have a dropdown that would allow the choice to change to other ad sizes from the drop down. Those would be zones.

Sponsor our Newsletter | Privacy Policy | Terms of Service