PDA

View Full Version : php


Zozart
28-02-2003, 00:41
Okay, im just getting the hang of this php thing right. I've got my nice and dandy (and valid xhtml :D) layout, and in the middle i've got (zyon being my variable):
<?php include ("$zyon.html"); ?>
now, that spits out an error message once that page (index.php) is uploaded and viewed, which is meant to happen anyway. So, I enter this url > index.php?zyon=home < and up comes the home page in the middle of the layout. Perfect. Now, what i'd like to know, is how to have stuff on my index page? ie. a php news script. Since at the moment, it seems to me, that to get to my news page im gonna have to type 'index.php?zyon=home' which won't be nice for visitors since i'm gonna be hosting this on a proper domain.

So how can I get the home/news page to display automatically upon the index.php opening? (and then obviously going away when another link is clicked)? Any help appreciated, thanks!

Zozart
01-03-2003, 12:45
Ooh, its okay, i got the answer now, if anyone else was wondering, you simply need to use this instead of the normal include code. (home.txt being the page you want displayed on the index page):

<?php

if (!$_GET['variable']) {
@include ('home.txt');
}
else {
@include ($_GET['variable'].'.txt');
}

?>

Gordy
01-03-2003, 14:07
Originally posted by Splaty
Ooh, its okay, i got the answer now, if anyone else was wondering, you simply need to use this instead of the normal include code. (home.txt being the page you want displayed on the index page):

<?php

if (!$_GET['variable']) {
@include ('home.txt');
}
else {
@include ($_GET['variable'].'.txt');
}

?>

Was wondering myself as I thought u first one was how to do includes , I've just got a couple of php books to learn it :)

Zozart
01-03-2003, 16:16
yeah, the first one works fine for normal includes, but when you include variables and want that effect, you need to use the second one, i guess. Anyway, it's actually a great and simple way to manage your site, since all your content is stored in itty bitty text files (or anything, but I use text files)