PHP menu

how to make php based menu bar

Page 1 of 1

8 Replies - 4376 Views - Last Post: 07 March 2009 - 02:37 PM Rate Topic: -----

#1 alimdar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-February 09

PHP menu

Post icon  Posted 25 February 2009 - 08:28 PM

Hi everyone,
I am totally new to the site and have basic html programming knowledge. I am a graphic designer trying to learn some web stuff.
I have a friend whose website I'd like to built. She runs a spa and the idea is pretty basic -the website would have around 20-30 pages.
I thought of making it as html / css, but the amount of pages made me think it should be php.

If I understand php concept well, it is used (one of the basic uses) when you have some parts of the website repeating on all of the pages. In this case we would have a menu, RSS feed and a contact form - these elements would stay the same / repeat on all the pages...would 'modules' be right word for it?

So I was hoping someone can give me hints / tutorial on how to make a php menu / RSS feed /
Is it that I make / style the menu as html first and then save it as a php file?
Then on each page within header's div add some php code that calls this menu.php page?

As I said, I am really new to php ))

Cheers
Alimdar

Is This A Good Question/Topic? 0
  • +

Replies To: PHP menu

#2 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: PHP menu

Posted 25 February 2009 - 08:34 PM

What you are looking for here is the <?php include("file.php"); ?> function. The advantage of this is the fact that instead of having to modify 20-30 static pages, you can modify your include files.

Here is an example of a totally dynamic site:

<?php

// Contains global variables, styles, and functions
include("library.php");

// Contains the page header (navigation, banner, ect.)
include("header.php");

// Determines what page the user is on,
// and what content to deliver to the page.
include("content.php");

// Contains the footer of the page
include("footer.php");

?>




With this type of design, you can turn a 5-6 PHP file project into a website that has 100,000+ unique pages (in terms of what the Search Engine sees).



If you have any more technical specific questions, feel free to ask and I'd be more than happy to assist you!
Was This Post Helpful? 1
  • +
  • -

#3 Moonbat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 424
  • Joined: 30-June 08

Re: PHP menu

Posted 26 February 2009 - 09:23 AM

Instead of having 20-30 actual pages, a good idea would be to only have a few pages that grab content from a database based on a GET variable in the URL. Done correctly, you can have a single index.php page. It will have a variable 'page' and based on the value of the page variable, you can grab content from your database that pertains to the value of page. If 'page' == 'About', then you would have a query to your database to grab text and image references associated with the 'About' page and show them on your index.php. You can do this for any page really.
Was This Post Helpful? 1
  • +
  • -

#4 sl4ck3r  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 285
  • Joined: 22-September 07

Re: PHP menu

Posted 26 February 2009 - 09:37 AM

You should definitely validate the get information before querying the database though.
Was This Post Helpful? 0
  • +
  • -

#5 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: PHP menu

Posted 26 February 2009 - 11:41 AM

I wouldn't deliver the entire page's contents based on MySQL queries... in my opinion, that is just bad practice. Not only does it put unnecessary strain on the server to render simple pages, but load times and efficiency will suffer as a result.
Was This Post Helpful? 0
  • +
  • -

#6 alimdar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-February 09

Re: PHP menu

Posted 06 March 2009 - 06:53 PM

Hello,
I'd try to find tutorials that explain me how to make a basic php layout, but after hours and hours of research I gave up...
None of the tutorials I could find wasn't helping me to apply some of the basic concepts.
For example, I am trying to make a simple structure for a website.
I have uploaded the jpg file of a layout here:
http://alimdardesign.com/eveil.jpg

Basically, I'd like to have the header with the menu that would stay the same on all of the pages.
Bellow it, I'd have div with either flash intro, for the home page, or various jpg's for the rest of the pages.
this Div would always be the same size, but the content would obviously change.
Next, I'd have the body - mostly consisting of text and some images - something that wold vary on each page.
And finally, a footer, always the same, on all the pages.

I understand I can built this structure as a basic index.php page and use it as a template for all the other pages.
But how to do that? how would I style it? How would that php page know where to place the menu / header, flash intro, body and footer?
moreover, where are these files (menu, divs with flash intro / jpg's, various pages with content, footer)?
are they html pages? php?
I am VERY confused...

I hope you have some time to help me out...
I don't even mind paying for any help, I am eager to built my first php website, it seems quite manageable task, yet, tutorials are all over the place, I find they lack focus, or are not concrete enough...or I am just not a tech savy but a frustrated designer ))

Alimdar
Was This Post Helpful? 0
  • +
  • -

#7 supersssweety  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 22
  • View blog
  • Posts: 373
  • Joined: 16-March 07

Re: PHP menu

Posted 06 March 2009 - 10:04 PM

I would recommend the includes, the menu itself doesn't have to be written in php, you can use html/css and even javascript if a menu like that is easier to find a tutorial for. You can name a file .php and not have any php in it. There really is no reason to make it a php menu if it is to complicated. I personally would try to find that style of menu using css or javascript, then plug it in via includes like pr4y said

EDIT: also if you are adamit about doing it in PHP just keep working with it. Trust your instincts, figuring it out is the best way to learn

EDIT AGAIN: If you decide to go the php route and you are having trouble, post the code and shots of whats not working and we will do our best to help you out

This post has been edited by supersssweety: 06 March 2009 - 10:10 PM

Was This Post Helpful? 0
  • +
  • -

#8 AlienWebguy  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 84
  • Joined: 04-March 09

Re: PHP menu

Posted 07 March 2009 - 02:30 PM

I'll never understand the whole concept of using a single index.php and making your database do all the work every time someone views your site.

An alternative to that which would take a ton of load off your CPU is to create cached pages. Say you code an admin CMS module. You can create your header and footer in the CMS which will simply "render what the header would look like" by grabbing and parsing all the appropriate HTML and writing it to its own html or xml file. Same for the footer, and same for every unique page you have on your site. You can set your CMS to acknowledge what type of page it is you're creating and then all the raw data will still be stored in the datbase so you can always edit it later, but the idea is simply that the database pulls the data only ONCE and writes it to an XML file with the header and footer include references written as well, and then when your users view the page, they're simply viewing cached markup, no DB query needed (unless of course you have realtime needs like a forum or whatnot.)

Just a thought if your cpu is strained. 2advanced did this with their current site which is why you can use the back button in your browser and bookmark nested pages, even though the site is flash.

--S--
Was This Post Helpful? 0
  • +
  • -

#9 sl4ck3r  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 285
  • Joined: 22-September 07

Re: PHP menu

Posted 07 March 2009 - 02:37 PM

www.tizag.com has a decent PHP tutorial, but i really like the O'reilly PHP and MySQL book. I wasn't suggesting you store the page information in the database, but merely saying if you're going to do it that way it is imperative you validate the information. Also if something in the page NEEDS to be there, like validation, use require_once instead of include.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1