Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Beginner's question - GET parameter mode

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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
$mode="something";
if (isset($_GET['mode']) && $_GET['mode']!=""){
  $mode=$_GET['mode'];
}

switch($mode){            
 case "gallery":
 require("gallery.tpl");
 break;
 
 case "picture":
 require("bigpic.tpl");
 break;
 }


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.

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

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. http://jream.com/learning/videos/php-oo ... mvc-part-1
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 783
Joined: Mon Oct 01, 2012 12:32 pm

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'];
jevin94
New php-forum User
New php-forum User
 
Posts: 9
Joined: Fri Mar 29, 2013 10:02 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.