我正在尝试从MySQL数据库中获取记录,以便使用PHP以HTML格式进行编辑。首先是用户点击EDIT超链接以编辑数据的代码。
<?php
$con=mysqli_connect("localhost","root","")or die("Connection error");
mysqli_select_db($con,"lecture7")or die("dbase error");
$sql="select * from students";
$result=mysqli_query($con,$sql);
echo "<table border=1>
<th>RollNo</th>
<th>Name</th>
<th>class</th>
<th>Update</th>";
while($row=mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo "<tr>";
echo "<td>";
echo $row['RollNo'];
echo "</td>";
echo "<td>";
echo $row['name'];
echo "</td>";
echo "<td>";
echo $row['class'];
echo "</td>";
echo "<td>";
echo "<a href='update.php?roll=".$row['RollNo']."'>
Edit</a>";
echo "</td>";
}
?>
Aftter点击EDIT用户将继续update.php进行编辑。但不是在文本框中显示记录而是发送错误警告:mysqli_fetch_array()期望参数1为mysqli_result,第11行的C:\ xampp \ htdocs \ update.php中给出布尔值这里是代码for update.php
<?php
$con=mysqli_connect("localhost","root","")or die("Connection error");
mysqli_select_db($con,"lecture7")or die("dbase error");
$r=$_GET['roll'];
$sql="select * from students where roll=$r";
$result=mysqli_query($con, $sql);
while($row=mysqli_fetch_array($result, MYSQLI_ASSOC))
{
?>
<form name="f1" action="" method="GET">
RollNo:<input type="text" name="txtr" value="<?php echo $row['RollNo'];?>"
Name:<input type="text" name="txtn" value="<?php echo $row['name'];?>"
Class:<input type="text" name="txtc" value="<?php echo $row['class'];?>"
</form>
<?php
}
?>