Web Design

K, though PHP can really make things easier just so ya know.
Oh and XHTML is just a stricter format of HTML.

Though just remember HTML by itself cannot really do anything with variables.
If you play to do anything like a counter, guestbook, poll, etc.. you will need PHP.(You could do it in Java(Javascript is not the same in any way obviously), though that wouldn't be at all user friendly).

If you wanna know how PHP can make this easier like editing your layout(so you edit it once and it goes for every single page) well i'm here. Though you could use frames, php would give more "browser support".

Anyway I should go work on my website.
 
Pressure, if you're looking at a left/right menu that displays on every page then you will probably will be needing to use PHP at some point. Unless you have a small amount of pages, but even so, i'd use it anyway.

You'd be looking at an include. Or using a header.php and a footer.php then wedging the page content in the middle.

Includes are very simple - "<?php include("menu.php"); ?>", with menu.php containing the code for the menu.

One problem is that normally only paid webhosts support PHP, and to test this offline you will have to run a webserver supporting PHP. Here's a good free one - http://www.aprelium.com (< 300kb)

EDIT: You posted while I was writing, eek.
 
Oh don't worry, my friend pays for his own 5 gig bandwidth site and I got my own section to be testing stuff on there.

So how does the code for menu.php know where to sync up with the standard template of the page?
 
Oh don't worry, my friend pays for his own 5 gig bandwidth site and I got my own section to be testing stuff on there.
Thats very good :)

Ok Pressure, it's quite simple.
Make your index.php
This is where all your code will go.

Now in index.php start everything like normal. When you have a .php extension all it means is that you can put php into that document.
Example,
<Html>
<Body Bgcolor=000000 Vlink=White link=White Alink=White>
<Table Width=100% Align=Center>
<Tr><Td><? Include("LeftMenu.php"); ?></Td></Tr>
<Tr><Td>News Text</Td></Tr>
<Tr><Td><? Include("RightMenu.php"); ?></Td></Tr>
</Table>
</Html>


Now you could put this for
LeftMenu.php

<Font Size=3>Links</Font>[br]
&nbspHalf-Life 2!!
&nbspGoogle
&nbspAlta Vista!!

Now this would look a little diffrent in XHTML as in XHTML things have to be Captilized a certain way.

Now what happens is,
When a client asks for your website,
the server will then place everything in LeftMenu.php into where it's called in index.php.
So thus the client recives this code:
<Html>
<Body Bgcolor=000000 Vlink=White link=White Alink=White>
<Table Width=100% Align=Center>
<Tr><Td>
<Font Size=3>Links</Font>[br]
&nbspHalf-Life 2!!
&nbspGoogle
&nbspAlta Vista!!
</Td></Tr>
<Tr><Td>News Text</Td></Tr>
<Tr><Td></Td></Tr>
</Table>
</Html>


Now that you probably understand how PHP works, you may be asking....ok so it saves some text to look at...
Well it can eventually do much more advanced things.(Much meaning.... well think of it this way, this forum is done in PHP.)

Once you tell me you understand that(which I'm pretty sure you do) I will give your a more inside look on how to make it so you can change the layout alot easier.
 
That's a very simple concept, I don't know how you couldn't understand. Let's say I do that method and I'm using CSS, is the text imported from leftmenu.php be affected if thats what the sheet was doing?
 
Mineral, using css would be alot better than using the font and body attributes, using classes and css rules would be better imo. Apart from that, it looks like a cool example
 
I figured(And hoped) that you could understand that lol.
Ok pressure, to answer you question I will put it in "logic"

Remember the clients browser does all the CSS stuff. The clients browser has no clue what php actually is.
So the client just gets the HTML, what do you think it will do?
It would my PHP concept just as much as if you wrote everything by hand in html.

So to answer you question, yes it would.

Now lets say you had a folder set up.
So instead of
<? Include("LeftMenu.php"); ?>
you had
<? Include("/Menus/LeftMenu.php"); ?>

Now what is also a bit nifty is this. All your links in LeftMenu.php will start from your index directory not the Menus directory.
This can actually be great for orginization.

Lets say you have 2 folders,
-Menus
---LeftMenu.php
-Pages
---About.php

Links in LeftMenu:
About
That is how they would go, because everything included goes back to index.php
Otherwize you would have to,
http://www.siteaddress.com/Pages/About.php

Anyway with php I am going to show you a few linking methods.
Here is a way to do a link:
About

Now make a document called: DocLinker.php
In this page you would put,

<?

Switch(GET_['page'])
{
Case About:
Include("Pages/About.php");
}

?>

Now in your news area put this: <? Include("DocLinker.php"); ?>

There you go. That is one way to do it. (I made my own little way though).

In About.php you can put whatever you want. You could put like:
<Table Width=100%>
<Tr><Td>The About Page</Td></Tr></Table>

Anyway, I use a similar yet diffrent approach.
if (substr($_GET['page'], 0, 3) =="Doc"){
Include($_GET['page']);}
else{Include('Documents/General/News.php');}

my links go like:
?page=Documents/General/About.php

Now all my pages are in /Documents/(except index.php)
Now I check the first 3 letters after the ?page to make sure they begin with Doc. If they do then it will get the full link and get that information.
Now if it does not begin with Doc it may mean that they went to: www.siteaddress.com. You see there is no ?page thus it does not being with Doc, therefor I use the else to make it come up with the news page.

Simple yet works extremely well. Currently this is my script:
<?
$IP="/min/?email=" . $_GET['email'];
$Ip2="/min/?page=" . $_GET['page'];
$Ip3="/min/";
switch($_SERVER["REQUEST_URI"])
{
case $Ip2:
if (substr($_GET['page'], 0, 3) =="Doc" || substr($_GET['page'], 0, 3) =="Cor"){
Include($_GET['page']);}
break;
case $IP:
$user="#####";
$password="#####";
$database="#####";
mysql_connect(mysql,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM LoginScript";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$Email=mysql_result($result,$i,"Email");
$i=$i + 1;
if($Email == $_GET['email']){ Echo("
Account Found, please type in your Key[br]
<form action='?page=Core/KeyFunction.php' method='POST'>
<Font Size=3>Key:</Font>
<input type='text' name='Unique'>
<input type='hidden' name='Email' Value='$Email'>
<input type='submit'>
");}
elseif($i == $num){echo('Sorry, either that email is not registered with us or it has already been registered. To register an account, please click "<U>Register Here</U>" near the top of the page.');}
}
mysql_close();
break;
case $Ip3:
Include('Documents/General/News.php');
break;
}
?>
This will auto confirm the registration email without making any extra pages. It will also direct to the right pages etc..

I don't expect you to understand\know this. I do believe you have done a bit in Java? So i'm guessing you would actually understand quite a bit of it, and if you really read it prehaps all of it.(Considering you know what mysql is).

Anyway you should get the Switch/If/While parts.
 
Mineral that code looks pretty impressive. I had a spare 10 mins so I made a practical example of your idea incase people didnt understand it. It doesn't have the code you just put up but it does have the side menu's and the main part using the suggestions you made. it is fully xhtml 1.0 valid and also teh css is valid too, as you can see i put on buttons to check that out. here is the link www.duffers20.com/stuff/main.php and you can find all teh php code in txt files in teh parent directory here www.duffers20.com/stuff/
 
Thx :).
I'm glad somebody thinks so :).

Though it's long.. I wouldn't say impressive exactly.. I mean to me it has just become a bunch of if's and loops. But then again I never really looked at to many other pieces of code except on tutorials.

Anyway I'm glad you took the time to make something to help anyone who dosn't fully understand that is browsing this topic :).

Infact when my friends online started doing php(I was 12 they were about 16), I really didn't like it or understand it to much for that matter. Then I just stopped with learning php for about a year..came back.. at 13..clicked...understood every little bit of it.. wierd ya know? Same with Mysql and the little C++ I did.

Anyway 14 now and look at me now :).
 
Personally, I use what I would call fake templates. Basically, I make a .php page with all the menus, header, footer etc. Then, where I want the main text to be displayed, I put <?php include $MainText; ?> That page is called Template.php. Now, if I want to make a page like this:

http://membres.lycos.fr/zepites/TemplateExample.jpg

I name it combat.php and put something like this:

<?php $MainText = "This is the main text that will be displayed.[br]<span class=\"SmallText\">I can even put html code here</span>"; ?>
<?php include "Template.php"; ?>
 
Minerel said:
...

Now this would look a little diffrent in XHTML as in XHTML things have to be Captilized a certain way.

...
Good example, but XHTML requires every tag to be lowercase. I normally wouldn't remark something like that but it is one of the core essences of xhtml :)
 
Good example, but XHTML requires every tag to be lowercase. I normally wouldn't remark something like that but it is one of the core essences of xhtml
Well I usually do everything in HTML not XHTML, so I really didn't know exactly.
 
Back
Top