Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

78 users online



Correct me if I'm wrong (again)

Correct me if I'm wrong (again)

Currently viewing this thread: 1 (0 members and 1 guests)


Page 3 out of 4
Rad

Rad

thinking of something witty to put here
Status: Offline!

I think you're confusing him about paths and stuff, as that would be an impractical use for a database.

How about an example? What will your site be about, Agatio?

Agatio

Agatio

Neversidian
Status: Offline!

Should have explained this eariler. Tongue
It;s a gaming site, one of the many. I naviagation bar, about 50 pages now, though more on the way. Simple layout.

http://shiningsoul-league.net
if you want a look.
I'm just interested as to how I can make my site have the "index.php?id=1" in the address bar and why.

Samurai_Zero

Samurai_Zero

Procrastination Guru
Status: Offline!

For your purpose, I don't think a database is needed for a couple of reasons: 1) all of your content pages are already written and 2) the page=bleh or id=4342344 in your address bar can be accomplish easily without the need for a database.

So check out the following code:

PHP:

<?php

// This makes the sites header html code a requirement, site will fail to load if this file is not present!
   
require_once("./header.inc");
   
// The following switch function grabz the 'page variable 
   
switch($_GET['page'])
   {
       case 
'about'// If page = about, then all php code between the semicolon (":") and the break; ("break;") will be done
            
include("./pages/$page.inc"); /* Just doing a simple include of a file located in the pages folder, 
                                             with the name of about.inc - This would be a content page */
       
break; // End this case of the switch

       
case 'links'// If page = links, then..... See first case for explanation
            
include("./pages/$page.inc");
       break;

       default: 
/* This is like your index, if page = anything besides 'about' or 'links' 
         this will be shown, or if page doesn't = anything, this will be the active case */
            
include("./pages/main.inc");
        break;
   }
   
// Include the footer html code, and make it a requirement!
   
require_once("./footer.inc");

?>

I do believe that is what you're looking for. Just take note that the file "./header.inc" would contain all of the html code that comes before your main content. And the file "./footer.inc" would contain all of the html code after your content.

The other files ("./pages/links.inc" , "./pages/about.inc" & "./pages/main.inc") would be your content pages. Those content pages would only have your content in them.

For example, if one page of your website had this code

Code:

<html>
<head>
<title>I forgot the doctype! doh!</title>
<!-- Put CSS HERE! meh... -->
</head>
<body>

<div>
<p><strong>Menu:</strong> <a href="?page=about" title="about">About</a> | <a href="?page=links" title="Links">Links</a> | <a href="?" title="Home">Home</a> |
<a href="?page=nonexistant" title="Fake">Free Apple Cider!</a>
</p>
</div>

<div><p>This is the home page, <em>gawd this layout sucks...</em></p>
<p>Alot of content goes here... Also, you can see how the links work. However, take note that the page=nonexistant link
would just show your "./pages/main.inc" file as that is the default, meaning if you don't have a case 'nonexistant':
then nonexistant isn't going to be included into your main page, this is a good thing.</p>
</div>

<div><p>Copyright © Some moron who should get a better layout - All rights reserved</p></div>

</body>
</html>

Well, if that was your page, then all of the html before

Code:

<div><p>This is the home page....

would be put into the header.inc file, and all of the code after the

Code:

....this is a good thing</p>
</div>

would be put into the footer.inc file.

And everything inbetween would be put into the "./pages/main.inc" file, as its the main page that moronic person would want displayed.

I'd explain further but I think my explanation would just confuse you further, I'm never write tutorials for a good reason.

___________________

Bored? Join us at #Central on irc.Neverside.com

Last edited by Samurai_Zero, November 14th, 2004 10:50 PM (Edited 1 times)

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

Just a note on Samurai_Zero's code, it won't work on servers with register_globals disabled (it's a PHP configuration that's now disabled by default). Also it's not the most efficient way... but it would get the job done (if you have register globals enabled).

It's my (and many others') recommendation to never do anything that requires register_globals, but since you're new, guess it won't matter that much...

___________________

Learn HTML

Agatio

Agatio

Neversidian
Status: Offline!

I am already using the include command to include my header and footer on ever page. I'm just wondering if there is an alternative for having 50 text files sitting on my server

I don't undertand this though:

Code:

// The following switch function grabz the 'page variable

switch($_GET['page'])

{

case 'about': // If page = about, then all php code between the semicolon (":") and the break; ("break;") will be done

include("./pages/$page.inc"); /* Just doing a simple include of a file located in the pages folder,

with the name of about.inc - This would be a content page */

break; // End this case of the switch

case 'links': // If page = links, then..... See first case for explanation

include("./pages/$page.inc");

break;

default: /* This is like your index, if page = anything besides 'about' or 'links'

this will be shown, or if page doesn't = anything, this will be the active case */

include("./pages/main.inc");

break;

}

theTrinity

theTrinity

David
Status: Offline!

You really have to just learn SQL. Get some scripts, go look in PHPMyAdmin, view some PHP sources with SQL in it. SQL isn't all that hard... mainly just... SELECT * FROM this WHERE this = that... blah blah... It's what you do to the data with PHP that makes it complicated.

PHP:

<?php
// The following switch function grabz the 'page variable 
   
switch($_GET['page'])
   {
       case 
'about'// If page = about, then all php code between the semicolon (":") and the break; ("break;") will be done
            
include("./pages/$page.inc"); /* Just doing a simple include of a file located in the pages folder, 
                                             with the name of about.inc - This would be a content page */
       
break; // End this case of the switch

       
case 'links'// If page = links, then..... See first case for explanation
            
include("./pages/$page.inc");
       break;

       default: 
/* This is like your index, if page = anything besides 'about' or 'links' 
         this will be shown, or if page doesn't = anything, this will be the active case */
            
include("./pages/main.inc");
        break;
   }
?>

You see switch($_GET['page']) at the top, right? Then you see case: blah, case: this. What this does is check the variable in swtich and then if that variable matches any of the cases you put, do whatever the case it matches says. I'm trying to make this sound easy enough for you to understand... So... if you go to blah.php?page=about, it would include "./pages/$page.inc"

http://us2.php.net/manual/en/control-structures.switch.php

Last edited by theTrinity, November 15th, 2004 06:02 AM (Edited 1 times)

Waldir

Waldir

God's Son
Status: Offline!

heh, just make a flat file database... store content and than explode it and include it into you header and footer, this will make your 50 txt files into one

___________________

"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

PhilDesign

PhilDesign

Status: Offline!

good for you faggot. ur learning

___________________

http://www.boomspeed.com/fearnbk/sig3.jpg

Rad

Rad

thinking of something witty to put here
Status: Offline!
Quote:

Originally posted by PhilDesign
good for you faggot. ur learning

?

Waldir

Waldir

God's Son
Status: Offline!
Quote:

Originally posted by PhilDesign
good for you faggot. ur learning

Heh, whoever you are talking to, thast not nice...
:mad:

___________________

"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

Page 3 out of 4
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0216 seconds.