Home > Backend Development > PHP Tutorial > 关于PHP100视频教程中的edit.php

关于PHP100视频教程中的edit.php

WBOY
Release: 2016-06-23 13:51:09
Original
1138 people have browsed it

视频教程的代码如下 ,作用为点击编辑选取数据库中  id="当前选取评论的id然后编辑其内容",数据库中ID设定的是auto_increment,视频教程上可以轻松获取出当前评论的数组,我却获取不到。在$sql="select * from `feedback` where `id`='".$_GET['id']."'";前加上echo 显示为select * from `feedback` where `id`=‘’ 为什么获取不到当前项的ID还是哪边代码错了,跪求各位大大帮忙!


回复讨论(解决方案)

你的url 上有?id=  这个查询字符串吗?

 

$sql="select * from `feedback` where `id`=".$_GET['id'];
Copy after login

ID查询不需要单引号。

if ( !empty($_GET['id'])){
//
}
当$_GET['id']不等于空时,才会继续执行,
除非你的$_GET['id']是空值,var_dump($_GET['id'])看看。

感谢一楼三楼 原因却是为ID为空 在URL中添加了href="edit.php?id="后终于成功获取到了数组。再次感谢!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template