drvxclagw656708070 2014-03-20 22:29
浏览 87
已采纳

如何清除php中链接中的参数?

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.

  • 写回答

2条回答 默认 最新

  • dtkmejg127475 2014-03-20 22:36
    关注

    The problem is that your href="evenement/..." is a relative URL and is getting appended to the current URL. You have two options:

    1. 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/..."

    2. Provide a base href in the <head> of the page, e.g. <base href="http://www.mywebsite.com/path/to/code/index.php/">.

    3. 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.'">';
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!