Reputation: 455
I am trying to make a condition of getting value but it is not working actually I have 3 pages and the layout of the page is same only the form is changed so what I am trying to do is if pagename?page is set then do something otherwise show recent activities in normal php it is easy to do by using isset() function but in codeigniter the isset function is not working here is what i did
<?php
if($this->input->get('page') == true) {
if($this->input->get('page') == true && $this->input->get('page') == 'page1') {
echo 'page 01';
}
if($this->input->get('page') == true && $this->input->get('page') == 'page2') {
echo 'page 02';
}
} else {
//normal activities page to be shown
}
?>
This is what I am trying to do but nothing is working for me like it's directly jumping to else condition can anyone help me our please if not clarified do ask me please.
Thank You and hoping to learn
Upvotes: 0
Views: 480
Reputation: 38609
In View
<a href="<?php echo base_url() ?>index.php/controller_name/order/one">Page One</a>
<a href="<?php echo base_url() ?>index.php/controller_name/order/two">Page two</a>
<a href="<?php echo base_url() ?>index.php/controller_name/order/three">Page three</a>
In Controller
public function order($value)
{
switch ($value) {
case 'one':
$page = 'one';
break;
case 'two':
$page = 'two';
break;
case 'three':
$page = 'three';
break;
default:
$page = 'three';
break;
}
echo $page;
}
Upvotes: 0
Reputation: 2677
Try this ;)
switch($this->input->get('page')) {
case 'page1':
echo 'page 01';
break;
case 'page2':
echo 'page 02';
break;
default:
/* normal activities page to be shown */
}
Upvotes: 1
Reputation: 714
Try This :
if($this->input->get('page')) {
if($this->input->get('page') == 'page1') {
echo 'page 01';
} else if($this->input->get('page') == 'page2') {
echo 'page 02';
}
} else {
//normal activities page to be shown
}
Upvotes: 1