corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Anyone know PHP? Bit of help needed...


New Topic

New Poll
  <<  1    2  >> Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Anyone know PHP? Bit of help needed...
AndyKent
Member

Registered: 3rd Sep 05
User status: Offline
24th Nov 06 at 13:44   View User's Profile U2U Member Reply With Quote

Yes thats fine.

But, for example, the links on my homepage change depending on whether you are logged in or not so I set up an array so my code could choose to use certain links or not......in this case you must create a function otherwise it all gets too confusing.

I think I'm right in saying that it is generally 'poor coding' to have includes all over the place - you should really include at the beginning of your main page and thats it....

[Edited on 24-11-2006 by aPk]
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
24th Nov 06 at 13:47   View Garage View User's Profile U2U Member Reply With Quote

so are you still getting an error? i cant see why your getting an error on line 51 when you done have 51 lines in either file, there must be more your not telling us
AndyKent
Member

Registered: 3rd Sep 05
User status: Offline
24th Nov 06 at 13:52   View User's Profile U2U Member Reply With Quote

I note that all my includes are actually 'require_once()' functions - have you tried this instead???
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Nov 06 at 14:08   View User's Profile U2U Member Reply With Quote

No mate, I fixed it ages ago, look at my post 4 posts down on page 1.

Basically it's a website for a car dealer up here in the north east. It will have a search function on so people can search for particular makes of cars, new/used etc.

But to save me doing 300 pages of navigation, I just wanted to make the links in header.php, so if I have to edit any of the links, I don't have to through 300 pages to edit a link

[Edited on 24-11-2006 by liamC]
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
24th Nov 06 at 14:10   View Garage View User's Profile U2U Member Reply With Quote

you could have also used an array to output the info to a template
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
24th Nov 06 at 14:30   View User's Profile U2U Member Reply With Quote

Like i said before..

Have a template.php and write the links in that.

then have the include in the area of the html where you want to include pages of information.

If you do it your way your still going to have to write the include into the top of 300 pages arent you.
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
24th Nov 06 at 14:35   View Garage View User's Profile U2U Member Reply With Quote

yep what im trying to say drax
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
24th Nov 06 at 14:35   View User's Profile U2U Member Reply With Quote

Make one page, index.php, design the body of the site in this. this is your template.

in the pit that will include page content you want a page reference variable, and a include which calls the pages named with that variable.

Which you see here

http://www.larkins-autoservices.com/

You only need to edit the css/index.php for changing the website template, you could also make things easier to change templates using css this way on the entire site.

if you wait till later ill show you the code that I use.
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
24th Nov 06 at 14:36   View Garage View User's Profile U2U Member Reply With Quote

i said that drax, then realised i couldnt be arse to write the code
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Nov 06 at 14:42   View User's Profile U2U Member Reply With Quote

You have to remember I don't know any PHP! I just use the net to find that tiny bit of code and get it working. I have no idea what variables and arrays are!!
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
24th Nov 06 at 19:26   View User's Profile U2U Member Reply With Quote

Okay, where you want your content to show up, but apply it to your stuff

code:
<?php
$page = $_GET["p"];


if (($page =="")) {include('htmlpages/about.php');

} else if($page == 'thanks') { include('htmlpages/thanks.php');
} else if($page == 'main') { include('htmlpages/main.php');
} else if($page == 'about') { include('htmlpages/about.php');
} else if($page == 'gallery') { include('htmlpages/gallery.php');
} else if($page == 'contact') { include('htmlpages/contact.php');
} else {include('htmlpages/error.php');
}

?>


as you can see, you define a word for each thing you want included..

the pages reside in their own folder on the root, called htmlpages

your links should look like this,

<a href="?p=main">Main</a>

you can see here that p=main which means with the php, if p is equal to main, it must include the .php file associated with it,

if you, or someone else trys to get somewhere, like to a page that isnt linked up they will be pointed to the error php.

simple

[Edited on 24-11-2006 by drax]
MarkPW
Member

Registered: 21st Jun 04
User status: Offline
24th Nov 06 at 20:33   View User's Profile U2U Member Reply With Quote

But then using the above method you're making it more difficult for yourself when designing your site using Dreamweaver or other software.

When you have the content page load headers/footers, Dreamweaver picks up the require() function, which will include your design and css styles. I personally code my layouts - for the most part - by hand, but I still prefer to have a visual representation in DW just so I don't have to keep saving and previewing in order to see if I've done something incorrectly. This is also useful for viewing the skeleton of the site.

Using the above method, although it does have it's advantages, it's going to take long where designing is concerned and for a newbie, it's not going to be any easier for them.

I've used the two methods described in this thread for various projects and I do prefer the simple require() in the content file - even though I realise it can be a pain sometimes!

Just my 2 cents
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
24th Nov 06 at 22:17   View User's Profile U2U Member Reply With Quote

why in gods name would you be using dream weaver to design your site?

if your going to learn to make websites, learn the back end of it so you at least know what you are doing and why the page is being displayed like it .

when designing sites I use photoshop to make images / initial design. and i use notepad or another textbased editor, editplus has a nice preview function.

thats all you should need.
MarkPW
Member

Registered: 21st Jun 04
User status: Offline
24th Nov 06 at 23:02   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by drax
why in gods name would you be using dream weaver to design your site?

if your going to learn to make websites, learn the back end of it so you at least know what you are doing and why the page is being displayed like it .

when designing sites I use photoshop to make images / initial design. and i use notepad or another textbased editor, editplus has a nice preview function.

thats all you should need.


So I guess you know all your doctypes off by heart then?

I use Dreamweaver as a design aid. I didn't say I used it to "design" my sites. I hand code in Dreamweaver - it doesn't make you any more skilled than I am just because you use notepad. Imho, you are mad! It must take you 5X longer than me to just insert a single image - but that doesn't mean to say I don't know how to hand code an image insert does it? Nor does it mean a newbie can't learn it from practicing with Dreamweaver, using the code and design views.

That's not to say though that Notepad (or Textpad in my case) aren't useful for minor updates, because they are.

Anyway - I think you're missing the point of this thread. The guy is a newbie, so why complicate things? Dreamweaver is a very useful tool for newbies and professional's alike, and likewise, the method he's using to include content into his pages is fine.

I could in fact say to you why not use a switch() statement instead of those long winded conditionals for your method of templating above. But you would say they both do the same thing. It's the same in this case - Dreamweaver does the same as Notepad, but offers 1000% more/better tools and it's not as long winded.

[Edited on 24-11-2006 by MarkPW]

[Edited on 24-11-2006 by MarkPW]

  <<  1    2  >>
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Meshed standard bumper Cursa Help Zone, Modification and ICE Advice 20 1375
17th May 03 at 01:33
by Miner
 
Car power help needed AdiSRI General Chat 1 552
19th May 04 at 22:59
by AdiSRI
 
website that sells GSi kits? L33 LEG General Chat 12 813
5th Apr 05 at 13:05
by FlameRedCorsa
 
Maths Help Needed - Binary (LOOK IN URGENT) RS6 Geek Day 5 615
24th Jul 05 at 22:40
by VegasPhil
 
F.a.o Fear Basscrazy Help Zone, Modification and ICE Advice 24 1622
24th Jan 06 at 22:48
by Basscrazy
 

Corsa Sport » Message Board » Off Day » Geek Day » Anyone know PHP? Bit of help needed... 29 database queries in 0.0157449 seconds