$result = mysqli_query($connection,"SELECT * FROM libsutdent where libid='$_POST[libid]'");
$rowcount=mysqli_num_rows($result);
if($rowcount==1)
{
while($row = mysqli_fetch_array($result))
{
$libid=$row['libid'];
$regno= $row['regno'] ;
$name= $row['stuname'] ;
$branch= $row['branch'] ;
$semester= $row['semester'] ;
$section= $row['section'] ;
$yearofadm= $row['yearofadm'];
}
}
答案 0 :(得分:3)
不要直接在数据库中发布任何内容,因为它对数据安全构成威胁(SQL注入)
$libid = $_POST['libid'];
$libid = mysqli_real_escape_string($connection, $libid);
$result = mysqli_query($connection,"SELECT * FROM libsutdent where libid='".$libid."'");
答案 1 :(得分:0)
确保你的mysql字段真的是libsutdent。好像它应该是libstudent。
然后在Post变量周围放置{}。即{$ _POST [\“libid \”]}。
相反,您可以在代码中添加另一个步骤,例如: $ libid = $ _POST [“libid”];
我认为你可以不使用libid周围的引号,但我一直认为添加它们会更好。
答案 2 :(得分:0)
$result = mysqli_query($connection,"SELECT * FROM libsutdent where libid='$_POST[libid]'");
应该是
$result = mysqli_query($connection,"SELECT * FROM libsutdent where libid='".mysql_real_escape_string($_POST['libid'])."'");