I need a little help.

jakeselectronics

New Member
Messages
38
Reaction score
0
Points
0
Hey everyone,

I have built a website and it has come to that time again where I need to expand my knowledge.

A bit of background....
I have writen my code in notepad for everypage, I haven't used a webpage dev program.
Every page is a .html.
So every page contains the layout (heading, menu, links..), plus the content of that individual page...

Everytime I add a new page I copy an existing one and and simply edit the content section.
If I want toi add a new link to the menu bar, I have to go to every page on my site and add it in manually.

As my page gets more and more content this is getting more and more tedious to add things.

I know there is a better way to build web pages... But I dont know where to start or look.

Here is my page for anyone that is interested.... http://www.jakeselectronics.x10hosting.com

Can anyone guide me to tutorials/give advice on how to better develope my website.
I know I could ask a Web deisgner, But i dont the funds, plus I want to learn how to do it...

Thanks,
Jake.
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
this is exactly why I use PHP.

the include() function is the best thing. just make one page that has your navigation, and include it in your template, when any page is called the navigation is called from that one page, and it will be updated on all pages...kinda confusing
 

jakeselectronics

New Member
Messages
38
Reaction score
0
Points
0
the principle isn't confusing. It makes good sense.

But I am confused how to go about it.

Got any good links to walk me through how it is done?
 

Sarnuial

New Member
Messages
6
Reaction score
0
Points
0
Here we go, PHP in five minutes.

To indicate the start and end of a block of PHP code, you've got to use PHP's start and end tags, like this:
PHP:
<?php

?>

In between those, you can use PHP functions. For example, the include function:
PHP:
<?php

include();

?>

Note the semicolon at the end of the line. All PHP instructions must end with a semicolon to signify to the interpreter that the command is finished.

Functions in most language take what are called "arguments". These are bits of information passed to the function that tells the function what to do or changes the way it does something. In PHP, these arguments are comma-delineated and placed in parentheses after the function name. If no arguments are to be given to the function, the parentheses must still be present, but should be empty. In the case of the include function, we need to pass the name of the file to include:
PHP:
<?php

include('file.inc');

?>

That will cause PHP to try to include the file file.inc (where "inc" is an abbreviation of "include") from the same folder as the script into the current output.

Note the single quotation marks around file.inc. These tell PHP that file.inc is a "string" - a set of characters that all go together. You can also use double quotation marks; there's a few differences, but that's beyond the scope of this post.

So, there you go, a crash course in PHP. To use any PHP, you'll have to rename your files to .php instead of .html; that way, the x10Hosting webserver will know that you want to parse the files with PHP. For further reading, check out the PHP tutorial at W3Schools.

Have fun!

--- Sarnuial
 
Last edited:

jakeselectronics

New Member
Messages
38
Reaction score
0
Points
0
Ok thanks.
I am about to have a go at changing some of my pages (then the whole site) over to php using includes.

Just another question before I do.

Say I have multiple pages that use an include for the header, links bar, menu and footer.....
Should the include file include table information such as sizes etc...
Or should the include file only include content, Therefore each individual page has contains the table information, then it calls the include file just for the content...

??
Bit confussing, please let me know if you cant understand what i am asking and ill re-phrase it...
 
Last edited:

Sarnuial

New Member
Messages
6
Reaction score
0
Points
0
I understand what you're asking. Really, it's up to you: go with whatever you think will be easiest to maintain in the long run based on how your HTML is laid out. My big suggestion, though, would be to forget about tables entirely and look into CSS-based layouts.

--- Sarnuial
 

playminigames

New Member
Messages
216
Reaction score
6
Points
0
also dont forget to rename all of your pages from .html to .php for them to work.

Good Luck!
 
Top