报错 Notice: Undefined index: id in D:\xampp\htdocs\web_health\main.php on line 65怎么改

<formid="form1"name="form1"method="GET"action="<?phpecho$_SERVER['PHP_SELF']?>"onsubm... <form id="form1" name="form1" method="GET" action= "<?php echo $_SERVER['PHP_SELF']?>" onsubmit="return Checker() " >
<p>
<label><input type="checkbox" name="item " value="personal_basic_information" id="chk_1" />基本信息表</label>

<label><input type="checkbox" name="item " value="principal_disease" id="chk_2" />重要疾病</label>

<label><input type="checkbox" name="item " value="baby" id="chk_3" />婴幼儿</label>

<label><input type="checkbox" name="item " value="pregnant_woman" id="chk_4" />孕产妇</label></p>
<input type="text" name="id" />
<p> <input name="查询提交按钮" type="submit" value="Submin" /><input type=reset value=重置></p>

</form>

<?php
$con = mysql_connect('localhost','root','');
if (!$con){
die('Could not connect: ' . mysql_error());
}else{
mysql_query("SET NAMES 'utf8'");
}
$identity_num = $_GET["id"];
$sql="SELECT * FROM web_health.personal_basic_information WHERE identity_num like('%"+".$identity_num."+"%')";
$query = mysql_query($sql);
echo "SELECT * FROM web_health.personal_basic_information WHERE identity_num like('%"+".$identity_num."+"%')";
echo $sql;
//echo $query;
$row=mysql_num_rows($query);
echo $row;
?>
展开
 我来答
Hzz_Green_Tea
推荐于2016-06-16 · TA获得超过104个赞
知道小有建树答主
回答量:171
采纳率:0%
帮助的人:151万
展开全部
改为这样就行了
$con = mysql_connect('localhost','root','');
if (!$con){
die('Could not connect: ' . mysql_error());
}else{
mysql_query("SET NAMES 'utf8'");
}
if(isset($_GET['id'])){
$identity_num = $_GET["id"];
$sql="SELECT * FROM web_health.personal_basic_information WHERE identity_num like('%"+".$identity_num."+"%')";
$query = mysql_query($sql);
echo "SELECT * FROM web_health.personal_basic_information WHERE identity_num like('%"+".$identity_num."+"%')";
echo $sql;
//echo $query;
$row=mysql_num_rows($query);
echo $row;
}
或者把这句$identity_num = $_GET["id"];改为$identity_num = @$_GET["id"];
更多追问追答
追问
array(8) { [0]=> string(1) "1" ["id"]=> string(1) "1" [1]=> string(18) "220106199001089015" ["identity_num"]=> string(18) "220106199001089015" [2]=> string(6) "陈某某" ["name"]=> string(6) "陈某某" [3]=> string(2) "男" ["sex"]=> string(2) "男" } 请问为什么指出来第一条数据 并且重复了?
追答
mysql_num_rows只是输出行数,那
array(8) { [0]=> string(1) "1" ["id"]=> string(1) "1" [1]=> string(18) "220106199001089015" ["identity_num"]=> string(18) "220106199001089015" [2]=> string(6) "陈某某" ["name"]=> string(6) "陈某某" [3]=> string(2) "男" ["sex"]=> string(2) "男" }由什么函数输出的。你说清楚
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式