Hi All,

I have been unable to successfully build a navigation system for my website, and I have been
through the thick of it for the longest time... Here is some background on the project:

First:

Tools used to create the navigation:

PHP / MYSQL

The object of this project:
To have a category navigation system done in php / mysql that when complete will show banner ads in different dimensions 468x60 and other sizes by category. The category navigation system will have a static number of categories but an unlimited number of subcategories. The subcategories and banner ads will display in adjustable columns using a variable (ex: cols=5) and the subcategories and banner ads will also use pagination to pagify (prev << 1 2 3 next >>) the results per page due to the large amount of content that will display in the subcateogry and banner pages.

I am using ad manager pro from: http://phpwebscripts.com/ad-manager-pro/

This category navigation in simple terms will be used as a front-end to the ad manager pro php script.

I am willing to offer payment via paypal for the project need be.

This is what I have so far (note: this was not done completly by me)

  <html>
<head><title>Navigation System in Progress...</title>
<style type="text/css">

a:link {margin:10px;}      /* unvisited link */
a:visited {margin: 10px;}  /* visited link */
a:hover {margin: 10px;}  /* mouse over link */
a:active {margin: 10px;}  /* selected link */

</style>
</head>


<body>

<?php

// Connect to the categories database
include('connect.php');

//Turn on error reporting
error_reporting(E_ALL);
ini_set('display_errors','Off');

$categories = array('');
$sub_cats = array('');

$cat_id = NULL;
$sub_cat_id = NULL;
$data = NULL;


// fetch all parent categories
$query = "select catid,name from categories where parentid = 0";
$result = mysql_query($query); // or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
    $categories[] = $row;

}


// check if a category has been selected, and if so, select its sub categories
if (isset($_GET['cat_id'])) {
    $cat_id = $_GET['cat_id']; // you should also validate the id. i.e. check that it is numeric and run it through mysql_real_escape_string()
    $query = "select catid,name from categories where parentid=$cat_id";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) {
        $sub_cats[] = $row;
   }

// check if a subcategory has also been selected, and if so, select its data
if (isset($_GET['sub_cat_id'])) {
$sub_cat_id = $_GET['sub_cat_id']; // you should also validate the id. i.e. check that it is numeric and run it through mysql_real_escape_string()
        $query = "select data from categories where id=$sub_cat_id and parentid=$cat_id";
        $result = mysql_query($query);
        $row = mysql_fetch_array($result);
        $data = $row['data'];
    }
}

// now, all relevant data has been selected. For simplicity, I'll just display it all
// echo '<pre>';
// var_dump($categories, $sub_cats, $data);
// echo '</pre>';


// You'll want to create category links as
foreach ($categories as $c) {
echo '<div>';
echo '<a href="cats.php?cat_id=' . $c['catid'] . '">' . $c['name'] . '</a>';
echo '</div>';
}

// ... sub categoires as ...
echo '<div id="subcats" align="center">';
if (!is_null($cat_id) && !empty($sub_cats)) {
foreach ($sub_cats as $c) {

echo '<a href="cats.php?cat_id=' . $cat_id . '&sub_cat_id=' . $c['catid'] . '">' . $c['name'] . '</a>';

 }

}


// ... and data as your previous code. So something like

if (!is_null($sub_cat_id) && !is_null($data)) {
$f = fopen('http://localhost/scripts/amp/show.php?z=' . $data . '&incl=1&ip='.getenv('REMOTE_ADDR').'&url='.urlencode(getenv('HTTP_HOST').getenv('REQUEST_URI')),'r'); 
echo stripslashes(fread($f,100000)); 
fclose($f);
}

?>  

Thank you in advance!
Brian

    Category naviation similar to what you see on the video music portal php melody...Note: The pop category shows subcategories. I am looking for a creative style to the subcategories. Also note the pagination at the bottom.

      Write a Reply...