【发布时间】:2018-10-10 13:48:11
【问题描述】:
我正在尝试使用 url 传递多个参数。我已经检查了几乎所有关于它的主题,但似乎找不到答案。我尝试了不同的方法,但仍然不起作用。
只发送第一个参数。
如果我以 post_id 开头 - 我无法获得 comment_id
如果我以 comment_id 开头 - 我不能得到 post_id
我对网址的看法:
http://localhost/index.php?post_id=3&comment_id=6
或
http://localhost/index.php?post_id=3&comment_id=6
我稍后尝试像这样使用它:
else if(isset($_GET['post_id']) & isset($_GET['comment_id'])){
$post_id = $_GET['post_id'];
$comment_id = $_GET['comment_id'];
$user_id = $this->UserModel->getUser();
$BlogPost = $this->BlogModel->getBlogPost($post_id);
$BlogComments = $this->BlogModel->getBlogCommentList($post_id);
$BlogComments = $this->BlogModel->deleteBlogComment($comment_id,$user_id);
include 'views/ViewBlogPost.php';
}
【问题讨论】:
-
您的第一个网址是正确的:
http://localhost/index.php?post_id=3&comment_id=6。看起来您可能正在使用 PHP——我感觉接收查询的代码中有一些不正确的地方。另外,看看这个,我觉得这很有帮助:en.wikipedia.org/wiki/Query_string