Beginner's question - GET parameter mode

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Thu Mar 21, 2013 5:04 am

Beginner's question - GET parameter mode

Postby phpchick » Thu Mar 21, 2013 7:29 am

First of all I want to say that I’m total beginner in php and so, this question may sound somewhat weird. But I need to write some php code for some school task. So, I hope you could help.
I have a so-called controller file: controller.php. And two template files – gallery.tpl and bigpic.tpl. First of them shows all small pictures, the second one is for big picture (one at a time on a page). I need to change the url so that, if I look at some big picture, the url will be something like controller.php?mode=picture&id=1. (I already managed to do this). But if I look at the gallery page, the url should be controller.php?mode=gallery.
How to do this? Should I put some link to controller.php file?
I’ve all the necessary code and also a switch statement:

Code: Select all

if (isset($_GET['mode']) && $_GET['mode']!=""){

 case "gallery":
 case "picture":

But still, it’s not enough yet. How can I tell the controller.php that the mode of the main (gallery) page – homepage - shoud be „gallery“. If I add gallery.tpl as a default value to switch statement, then it won’t set this mode the way I want it.


php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: Beginner's question - GET parameter mode

Postby seandisanti » Thu Mar 21, 2013 12:23 pm

check out Jreams's create your own mvc series. it takes him a little bit to really get going but it will answer this question fairly early on. ... mvc-part-1

New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 29, 2013 10:02 am

Re: Beginner's question - GET parameter mode

Postby jevin94 » Fri Mar 29, 2013 10:36 am

use the link such as controller.php?mode=abc and in other link use controller.php?mode=def

then fetch the value of mode in other page via get[''];

e.g. $mode=$_GET['mode'];

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 7 guests