Tuesday, 18 September 2012

Difficulty building my website

So I'm building a website that I'm going to be able to use at the end of November to start up my business but I've ran into some problems.... Well not really problems just making things a lot more complicated for myself but at the moment I honestly can't think of any other way that I can do what I want to other than this way.

So I have a website with a navigation bar at the top of the page for example Home, Contact Us, About Us, Videos etc. You should get the idea. So say you are on 'Home' the tab for you to be able to click home should already be highlighted so you know where on the page you are.

To do this I made a function that I included on every page called 'links()'. On the index page (Home page) it should be 'links(0)', on the Contact Us page it should be links(1) etc. I got it to work but it's way to complicated.

The way I managed to get this to work was make a function in my multi_page.php file called links ($x) and in this function I had a switch statement that looks like:

switch($x){
case 0:
$home = 'style="background-color:#eee9e9;text-shadow:1px 1px 3px black;"';
break;

case 1:
$contact= 'style="background-color:#eee9e9;color:#303030;text-shadow:1px 1px 3px black;"';
break;

case 2:
$about= 'style="background-color:#eee9e9;text-shadow:1px 1px 3px black;"';
break;

}

The problem with this though is eventually if the site has more and more different tabs and I decide to change something I will have to go through every individual line in the switch statement to change the code. Does anyone have any idea how I can make this easier?

No comments:

Post a Comment