Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

184 users online



query strings?

query strings?

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


colincameron

colincameron

Neverside Newbie
Status: Offline!

query strings?

Im following a tutorial on query strings and i get the idea, but is it possible to have more than one on a page. Like one for nav and one for content.

here is an example of the content one?

PHP:

<? 
         $page 
= $ GET["page"];          
         if ((
$page == "home") or ($page == "")) {          
         echo (
"Home page goes here."); 
         } else if(
$page == "about") {          
         echo (
"About page goes here."); 
         } 
         
?> 
         


Can these be placed in a php include? and instead of "page goes here." could i put another php include to the page i want to be loaded.

If more than one can be put on a page how does the url look?
index.php?page=about

Last edited by colincameron, July 3rd, 2003 02:17 AM (Edited 1 times)

Jeremie

Jeremie

Neversidian
Status: Offline!

the url look like

index.php?var1=value1&amp;var2=value2&amp;varx=valuex

&amp; is the html entity for &

___________________

Jeremie - Used to be the Director of Community Development

Err0r

Err0r

Status: Offline!

i dont even know why people use arrays when they are making query strings. whoever said arrays were needed is totally wrong.
all you heend is a varialble and an IF() statement

url example modernvisions.net/index.php?page=news

<?PHP

if ($page == "news") {

include("news.php");

}

?>

?>

___________________

Signature Suspended as it is in violation with the signature rules

Jeremie

Jeremie

Neversidian
Status: Offline!

Err0r.. wow that is a great name, goes well with your PHP skills.

using global variables isn't recommended for security reasons, and on PHP5 they wont be registered by default (read the security links in the sticky thread).

Plus, you dont check if the variable is set, which output a notice level error if it isnt set.

Even more, you use double quotes without any need (you only need double quotes when including variables and escaped characters in strings)

What more, by using the global variable, you dont know where that var comes from (get, post, cookie, environment, server)

not only the sample you posted will gives notice level errors (even these are really bad and look unproffessional) it wont run on the majority of PHP5 servers

___________________

Jeremie - Used to be the Director of Community Development

colincameron

colincameron

Neverside Newbie
Status: Offline!

so i should use the way i posted?

and i can put more than one of these arguments (if that is what they are called) on one page?

Jeremie

Jeremie

Neversidian
Status: Offline!

you can use as much as you want.
use ? to separate the path from the variables:

path <- ? -> variables
index.php?var=1

and use & to separate the variables (if you use this in html, use &amp; instead)
index.php?id=1&amp;page=15&amp;order=name&amp;desc=1&amp;filename=test.php

that's easy, you'll quickly get used to it

___________________

Jeremie - Used to be the Director of Community Development

Phil

Phil

with Mr. Jones
Status: Offline!

http://tutorialforums.com/showthread.php?s=&threadi ... 0&highlight=ares

___________________

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

Jeremie

Jeremie

Neversidian
Status: Offline!

even better Ares Shocked

___________________

Jeremie - Used to be the Director of Community Development

Quick Jump:

Main Navigation


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


NeverAPI generated this page in 0.008 seconds.