【问题标题】:Assist me in fixing the URL and created links please请协助我修复 URL 并创建链接
【发布时间】:2012-02-13 07:25:27
【问题描述】:
<?php    

    $res=$comments->result_array();
    $i=1;
    $ar=array();
    foreach($res as $row){
        $a=array($i,$row['title'],$row['date_post'],
            $row['date_edit'],
            '<a href="edit_post?title='.$row['title'].'">Edit</a>',
            '<a href="delete_post?title='.$row['title'].'">Delete</a>');
        array_push($ar,$a);
        $i++;
    }    
    echo $this->table->generate($ar);
    echo $this->pagination->create_links();
?>

我在我的页面中添加了两个链接(编辑和删除),这篇文章前面是这个href issue in view-controler

上一个帖子的解决方案让我在处理上述源 sn-p 中创建的每个链接的 URL 时更加困惑,例如 http://localhost/blog/get_comments/edit_post?title=something/,而我期望像 http://localhost/blog/edit_post?title=something 这样的东西。我很感激任何帮助。谢谢。

更新

上面的源代码可以正常工作,直到我点击上面代码中创建的编辑或删除链接,这会将 URL 解析为http://localhost/blog/get_comments/edit_post?title=something/,而我期望类似http://localhost/blog/edit_post?title=something。

【问题讨论】:

  • 你的问题很不清楚。你能把它改写得更清楚吗?

标签: php html codeigniter url


【解决方案1】:

更改 URL,因为它们似乎是相对的...

'<a href="edit_post?title='.$row['title'].'">Edit</a>',
'<a href="delete_post?title='.$row['title'].'">Delete</a>');

应该是:

'<a href="http://localhost/blog/edit_post?title='.$row['title'].'">Edit</a>',
'<a href="http://localhost/blog/delete_post?title='.$row['title'].'">Delete</a>');

如果它只出现在一个地方,那么你也许可以逃脱:

'<a href="../edit_post?title='.$row['title'].'">Edit</a>',
'<a href="../delete_post?title='.$row['title'].'">Delete</a>');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-07
    • 2012-04-15
    • 1970-01-01
    • 2014-01-22
    • 1970-01-01
    • 2013-07-27
    • 2011-02-28
    • 1970-01-01
    相关资源
    最近更新 更多