Hi i'm working on a calender when you click a day it shows you all tasks for that day. this is the code in the view.
$calendar.= '<td class="calendar-day">';
$calendar.= '<a href="evenement/showTaken/day/'. $list_day .'/maand/'.$month.'/jaar/'.$year.'">';
$calendar.= '<div class="day-number">'.$list_day.'</div>';
/** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/
$_evenement = new evenement();
$taak = $_evenement -> dateChecker($list_day,$month,$year);
$calendar.= $taak;
$calendar.= '</a></td>';
this is the code in the controller
public function showTaken(){
$this->load->model('model_taak');
$get = $this->uri->uri_to_assoc();
$dag = $get['day'];
$maand = $get['maand'];
$jaar = $get['jaar'];
$datum = date('M Y', mktime(0,0,0,$maand + 1,0,$jaar));
$this->load->template('view_evenement', 'evenement', array(
'maand' => $maand,
'jaar' => $jaar,
'datum' => $datum,
'infovandaag' => $dag.'/'.$maand.'/'.$jaar,
'taakvandaag' => $this->model_taak->takenByDate($dag.'/'.$maand.'/'.$jaar)
the problem i have is that when i click multiple days after eachother the link ends up something like this and will keep showing the first day clicked.
/code/index.php/evenement/evenement/showTaken/day/2/maand/2/jaar/evenement/showTaken/day/3/maand/03/jaar/evenement/showTaken/day/4/maand/03/jaar/evenement/showTaken/day/4/maand/03/jaar/2014
any idea how i could solve this? this is the first time i post here so i hope i gave you enough information.
The problem is that your href="evenement/..."
is a relative URL and is getting appended to the current URL. You have two options:
Place an absolute URL in your code, e.g. href="http://www.mywebsite.com/path/to/code/index.php/evenement/..."
or href="/path/to/code/index.php/evenement/..."
Provide a base href in the <head>
of the page, e.g. <base href="http://www.mywebsite.com/path/to/code/index.php/">
.
Use $_SERVER['REQUEST_URI']
to generate an absolute URL.
Here is an example for #3:
<?php
list ($url) = explode('index.php/', $_SERVER['REQUEST_URI']);
$calendar.= '<a href="'.$url.'/evenement/showTaken/day/'. $list_day .'/maand/'.$month.'/jaar/'.$year.'">';
?>
Try to add a leading slash '/' in front of "event" on your second line :
$calendar.= '<a href="/evenement/showTaken/day/'. $list_day .'/maand/'.$month.'/jaar/'.$year.'">';
Or even better, use CodeIgniter url generation :
$calendar.= '<a href="<=site_url('/evenement/showTaken/day/'.$list_day.'/maand/'.$month.'/jaar/'.$year);?>">';