Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

87 users online



Tutorial: page.php?page=blah / query strings / easy template tutorial (UPDATED)

Tutorial: page.php?page=blah / query strings / easy template tutorial (UPDATED)

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


Page 3 out of 15
KungPaoChicken

KungPaoChicken

Status: Offline!

the differnce, case is faster for more things i guess, and eaiser if your gonna have like 10 vars, instead of if then if then if then if then if then.

___________________

i stupended my own signarture

JohnSaunders

JohnSaunders

Neverside Newbie
Status: Offline!

So is case the same thing as if or else and break is the same thing as a closing bracket }?

I have like 10 sub-navigation links in some of my sub-navigation links. Could somebody give me an example of how I can trim my code down some more instead of having to include the <p class="subnav" ...etc... in each line? How could I do this using the switch statements?

Thanks for the help. It is much appreciated.

___________________

Best Regards,

John Saunders

not_taken

not_taken

Status: Offline!

I know I probably sound really dumb, but why would I want to do this, why not just have say links.php instead of whatever.php?page=links.

Phil

Phil

with Mr. Jones
Status: Offline!
Quote:

Originally posted by S3pyh
LOL after SO MANY HOURS ive worked it out and its so newbieish what it was.

I do know quite alot of php and have been building my site (http://www.code-9.com) for quite some time now.

You guys should really make clear all the query code needs to be in a TOTALLY SEPERATE PHP FILE to everything else. THIS IS REALLY WHAT I THINK PEOPLE ARE GETTING WRONG!

Iwas putting this code into my index/home.php and thats why it was f***ing up.

I feel such a newb now but you live and learn!

Not really...what are you talking about?

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

TrigBoy

TrigBoy

Status: Offline!

yeh it could be used for comparing.

eg

PHP:

<?php

If($_1337['DirectWD'] > $_1337['TrigBoy'])
  {
    echo 
"Neg";
  }
else
  {
    echo 
"Thats more like it";
  }

?>


It'd be great for a user community like www.sogamed.com Wink

Vector

Vector

Status: Offline!
Quote:

Originally posted by not taken
I know I probably sound really dumb, but why would I want to do this, why not just have say links.php instead of whatever.php?page=links.

The primary benefit is ease of changes. With this, each source file contains only the content part of the page while the central one has all the formatting.

For example, if you add another page to the listing, you only have to change your nav bar in one place rather than every page with it. For sites that use a nav bar, of course.

Another benefit is the centralization of everything. It removes the need to make every file be able to stand-alone. For example, let's say you had the following:

PHP:

<?php
define
("SQL_USERNAME""blah");
define("SQL_PASSWORD""blahblah");
define("SQL_HOST""localhost");
?>

In this method, you would only need those defined in the central file no matter how many others used it. In a stand-alone page layout, each file would need its own copy and would be much harder to change.

Pouq

Pouq

I'm Rick James, *****!
Status: Offline!

Sad , ok i know query strings but... i need one that i dont need to go edit a file just to add another page, like have it so it "auto" adds like phpNuke, all you do is add the page to the directory and it used the first work like index.php?page=pagename i would really like one of those:confused: Smile

___________________

http://www.gudio.com/scotty_sig.gif

Dev1

Dev1

Just a guy.
Status: Offline!
PHP:

<?php

switch( $_REQUEST['page'] ) {
    case 
'news' :
        include 
'news.php';
        break;
    case 
'portfolio' :
        include 
'portfolio.php';
        break;
    case 
'bush' :
        include 
'go_to_war_with_iraq_for_no_reason.php';
        break;
    case 
'me' :
        print 
'war sucks... GO ANTI WAR ME';
    default:
        include 
'news.php';
        break;
}

?>


Smile fixed it, typed it incorrectly.

Last edited by Dev1, April 17th, 2003 09:22 AM (Edited 1 times)

CDude

CDude

nothing
Status: Offline!

error

___________________

http://celerondude.com

Dev1

Dev1

Just a guy.
Status: Offline!

typed it wrong, but you get the idea.

Page 3 out of 15
Quick Jump:

Main Navigation


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


NeverAPI generated this page in 0.0111 seconds.