By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

SWITCH with a $_GET

P: n/a
I have a url that ends with ?pid=sqlall. I am using the following to
try and get at the "sqlall". I have read many sites to no avail.

switch ($_GET['pid']) {
case 'sqlall':
$page->assign('pagetitle', 'All Users');
$page->assign('tableheader', 'All Users');
$page->assign('sqlfile', 'sql_all.php');
break;
case 'sqlprof':
$page->assign('pagetitle', 'All Users');
$page->assign('tableheader', '» All User Profiles');
$page->assign('sqlfile', 'sql_prof.php');
break;
}

if the url is http://localhost/main.php?pid=sqlall or ?pid=sqlprof then
I want to case to assign. This is in conjuction with Smarty.
Any suggestion would be helpful.

Robert

Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
*** si*****@gmail.com escribi/wrote (7 Dec 2004 12:03:21 -0800):
I have a url that ends with ?pid=sqlall. I am using the following to
try and get at the "sqlall". I have read many sites to no avail.

switch ($_GET['pid']) {
case 'sqlall':


So, what's your problem? Have you done any sort of debugging, such us
printing the variables? Is that the URL of current page or some other you
have in a string?

--
-+ lvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informticas recibidas por correo irn directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
Jul 17 '05 #2

P: n/a

Alvaro G. Vicario wrote:
*** si*****@gmail.com escribi/wrote (7 Dec 2004 12:03:21 -0800):
I have a url that ends with ?pid=sqlall. I am using the following to try and get at the "sqlall". I have read many sites to no avail.

switch ($_GET['pid']) {
case 'sqlall':
So, what's your problem? Have you done any sort of debugging, such us
printing the variables? Is that the URL of current page or some other

you have in a string?

I have a "print_r" printing the $_GET. It IS displaying the right
string but my assign statements are not assigning anything. I am
calling the link from a JS using the following format:
"attu.php?pid=sqlall"

I am getting the "sqlall" it does not seem to be processing my assign->
parameters in the switch statement itself.

Robert

Jul 17 '05 #3

P: n/a
It seems to be the Smarty cache causing the problem. Because I am using
one page name "attu.php" the cache doesn't really see the change when I
do different assigns to it. I turned the Smarty cache off and bingo the
switch statement works.

Robert

Jul 17 '05 #4

P: n/a
On 8 Dec 2004 10:30:27 -0800, si*****@gmail.com wrote:
It seems to be the Smarty cache causing the problem. Because I am using
one page name "attu.php" the cache doesn't really see the change when I
do different assigns to it. I turned the Smarty cache off and bingo the
switch statement works.

It'd still be a bit better to do this:

$pid = $_GET['pid'];

switch ($pid) {
case 'sqlall':

....

--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
DataBasix | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ۳
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================
Jul 17 '05 #5

P: n/a
Gary L. Burnore <gb******@databasix.com> wrote:
It'd still be a bit better to do this:

$pid = $_GET['pid'];

switch ($pid) {
case 'sqlall':

...


Huh! Why?

Jul 17 '05 #6

P: n/a
si*****@gmail.com wrote:
It seems to be the Smarty cache causing the problem. Because I am using
one page name "attu.php" the cache doesn't really see the change when I
do different assigns to it. I turned the Smarty cache off and bingo the
switch statement works.


See the msarty manual how to have multiple caches for 1 page:
http://smarty.php.net/manual/en/cach...ple.caches.php

Jul 17 '05 #7

P: n/a
On 09 Dec 2004 19:12:20 GMT, Daniel Tryba <sp**@tryba.invalid> wrote:
Gary L. Burnore <gb******@databasix.com> wrote:
It'd still be a bit better to do this:

$pid = $_GET['pid'];

switch ($pid) {
case 'sqlall':

...


Huh! Why?


Moving the $_GET stuff in to their own variables is a good habit to
get into for more than one reason. One is less typing on re-use.
It's easier to type $pid more than once rather than typing
$_GET['pid'] more than once for example.

--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
DataBasix | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ۳
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================
Jul 17 '05 #8

P: n/a
Gary L. Burnore <gb******@databasix.com> wrote:
It'd still be a bit better to do this:

$pid = $_GET['pid'];

switch ($pid) {
case 'sqlall':

...


Huh! Why?


Moving the $_GET stuff in to their own variables is a good habit to
get into for more than one reason. One is less typing on re-use.
It's easier to type $pid more than once rather than typing
$_GET['pid'] more than once for example.


That must be the worst reason I ever heard! Offcourse varriables should
be to the point and descriptive. But that doens't mean shorter is
always better.

But $_GET['pid'] says something extra, like that it came from an
untrustworthy source. Making a raw copy hides that fact, so when $pid is
later used in output there is a chance that correctly escaping will be
forgotten.

Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.