<?php
mysql_connect("localhost","root","");
mysql_select_db("sample") or die("database could not connect ");
?>
<html>
<head>
<meta name="description" content="Php Code for View, Search, Edit and Delete
Record" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View Student Record</title>
</head>
<body>
<center><h1><u>Student Database</u></h1></center>
<?php
$roll=$_GET["roll"];
$query="select * from student where roll='$roll'";
$result=mysql_query($query);
while ($row = mysql_fetch_array($result)) {
}
?>
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
align="center" border="1">
<tr>
<td colspan="4" style="background:#0066FF; color:#FFFFFF; font-size:20px">VIEW
STUDENT DATABASE</td></tr>
<tr>
<td> Roll Number</td><td><? echo $row[0];?></td>
<td> Class</td><td><? echo $row[1];?></td>
</tr>
<tr>
<td> Name of Student</td><td><? echo $row[2];?></td>
</tr>
<tr>
<td>Sex</td><td><? echo $row[3];?></td>
<td>Address1</td><td><? echo $row[4];?></td></tr>
<tr>
<td>Address2</td><td><? echo $row[5];?></td>
<td>Address3</td><td><? echo $row[6];?></td></tr>
<tr>
<td>Remarks</td><td><? echo $row[7];?></td></tr>
<tr>
</table>
<p align="center"><a href="index.php">Go Back to Home</a></p>
</body>
</html>
那是我的代码
<?php
$roll=$_GET["roll"];
$query="select * from student where roll='$roll'";
$result=mysql_query($query);
while ($row = mysql_fetch_array($result)) {
}
?>
这是我的问题。我不知道如何摆脱这个错误:
注意:未定义的索引:在第 16 行滚动 C:\xampp\htdocs\sample\view.php
第 16 行是$roll=$_GET["roll"];
.
此代码应在每一行中显示信息,但当我运行它时,它什么也没显示。