
July 3rd, 2003
02:14 AM
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?
<?
$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)

July 3rd, 2003
02:19 AM
Neversidian
Status: Offline!
the url look like
index.php?var1=value1&var2=value2&varx=valuex
& is the html entity for &
___________________
Jeremie - Used to be the Director of Community Development

July 3rd, 2003
02:36 AM
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

July 3rd, 2003
02:52 AM
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

July 3rd, 2003
04:32 AM
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?

July 3rd, 2003
04:43 AM
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 & instead)
index.php?id=1&page=15&order=name&desc=1&filename=test.php
that's easy, you'll quickly get used to it
___________________
Jeremie - Used to be the Director of Community Development

July 3rd, 2003
03:13 PM
with Mr. Jones
Status: Offline!
http://tutorialforums.com/showthread.php?s=&threadi ... 0&highlight=ares
___________________
http://www.philbrodeur.com - Expert PHP Development and Tutorials

July 3rd, 2003
03:24 PM
Neversidian
Status: Offline!
even better Ares 
___________________
Jeremie - Used to be the Director of Community Development