0

hello, i am building a website using mysql and php on an apache web server. The site has over 100 index pages for differnt parts and content of the site.

one of the problems i am having is i have to write the navigation bars in for each page, and there are more then 100 index's

At present i have two navigation bars a Main and a Side, I want the main to stay the same all the way thru the site, but i would like the Side to change depending on what parent site the user goes to.

currently i have written boths bars into each page which is becomming very tedious, so i would like to create a php include file which would collect the data from the data base and arrange the data on the site.

I have 3 databases. which are as follows

1. nav_main - id.......- main id - primary - auto increment
.................name.....- name of page
.................url_link.- link to page
.................url_img..- link to image which i want to be displayed and linked

2. nav_sub - sid......- sub id - primary - auto increment
..............pid......- parent id - linked with nav_main id
..............name.....- name of page
..............url_link.- link to page
..............url_img..- link to image which i want to be displayed and linked

3. nav_ssub - ssid.....- ssub id - primary - auto increment
..............spid.....- sub parent id - linked with nav_sub sid
..............name.....- name of page
..............url_link.- link to page
..............url_img..- link to image which i want to be displayed and linked

as i have said the database are relationed together for example

¦ssub...........................¦sub......................¦main..........
¦-------------------------------¦-------------------------¦--------------
¦programming.-.ssid:17.spid:4...¦computers.-.sid:4..pid:2.¦books..-..id:2
¦tips........-.ssid:2..spid:1...¦art.......-.sid:1..pid:2.¦books..-..id:2
¦lions.......-.ssid:20.spid:14..¦animals...-.sid:14.pid:3.¦images.-..id:3

above is an example of how i hope i have set it up =)

main stays the same across the top and sub is down the side but ssub would become visable down the side if a sub page is selected.

I hope i have explained this well enough. I am rather new to PHP and MYSQL, If anyone is able to advise me i would be greatful

Thanks in advance

Smiler89
--------------------------------------------------------------------------
Data should be free!
Information is organised data... so
Information should be free!
--------------------------------------------------------------------------

Edited by smiler89: n/a

4
Contributors
8
Replies
11
Views
7 Years
Discussion Span
Last Post by EverWebby
0

sorry about the format =\ hope it can be read msg me if you would like more information

1

use this function to write your navigation i think it help you

function buildNav() {
global $_SERVER;
$url = array('index'=>'Home','about'='About','services'=>'Services','portfolio'=>'Portfolio','contact'=>'Contact','support'=>'Support');
$myNav = "<ul>"
foreach ($key=>$value in $url) {
if($_SERVER == "/$key.php") {
$active = ' class="active"';
}
else {
$active = "";
}
myNav .= "<li$active><a href='/$key.php' title='$value'>$value</a></li>";
}
$myNav .= "</ul>";
return myNav;
}

Votes + Comments
Prompt to the mark with advice and understanding
0

use this function to write your navigation i think it help you

function buildNav() {
global $_SERVER;
$url = array('index'=>'Home','about'='About','services'=>'Services','portfolio'=>'Portfolio','contact'=>'Contact','support'=>'Support');
$myNav = "<ul>"
foreach ($key=>$value in $url) {
if($_SERVER == "/$key.php") {
$active = ' class="active"';
}
else {
$active = "";
}
myNav .= "<li$active><a href='/$key.php' title='$value'>$value</a></li>";
}
$myNav .= "</ul>";
return myNav;
}

Thank you for attempting to help me, could you possibly explain what it is you have done so i can get a better understanding, I have spent past day looking at it with no luck =\ Thank you again, i am new too all this.

0

This may be somewhat irrelevant, but if you're new to this, why are you building a site with over 100 pages?

0

This may be somewhat irrelevant, but if you're new to this, why are you building a site with over 100 pages?

No that is a fair Q, im attempting to learn, i have to start somewhere, been reading books for ever, needed to do something practical. I have attempted it myself, I can use a computer rather well, and i have been useing HTML an CSS for a few years, i thought php would be better.

1

Several years ago, I was writing a cms similar to what your talking about. The problem with calling out to the database to reproduce the navigation menu on each page request is that its a pointless use of server resources and delay. From your administration, create a cache file on every admin update. This way your front end can just call the cache file.

Votes + Comments
Thinks outside the box.... I like that
0

Several years ago, I was writing a cms similar to what your talking about. The problem with calling out to the database to reproduce the navigation menu on each page request is that its a pointless use of server resources and delay. From your administration, create a cache file on every admin update. This way your front end can just call the cache file.

I think i may know what you are on about, do you mean so i only have one HTML index page, and all the other pages PHP puts together using includes on request? can php compile HTML? Like i say im new to this am tring to learn tho.

EDIT - Or did you mean create a cache on users computer containing all nav information? that seem like a good idea, but the idea was so i didnt have to write the nav for each index and sub page =\

Edited by smiler89: n/a

0

No I meant to create to output the text to a text file on the server with your administration and then just call that file to bring it into the front-end. The static file include will be alot less resource intense then calling to the database for every page request.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.