<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table id="users" border="1">
<tr>
<td>ID</td>
<td>Name</td>
<td>Age</td>
<td>Email</td>
<td>DOB</td>
</tr>
<tr>
<td>1</td>
<td><input size=25 type="text" id="Name" readonly=true/></td>
<td><input size=10 type="text" id="Age" readonly=true/></td>
<td><input size=25 type="text" id="Email" readonly=true/></td>
<td><input size=10 type="date" id="DOB" readonly=true/></td>
</tr>
</table>
<?php
$con = mysql_connect("127.0.0.1","root","test") or die(mysql_error());
$db = mysql_select_db("lr") or die(mysql_error());
$sql=mysql_query("SELECT * FROM user ")or die(mysql_error());
$count=0;
while($row = mysql_fetch_array($sql))
{
$name=$row['Name'];
$age=$row['age'];
$email=$row['Email'];
$dob=$row['DOB'];
echo '<table id="users" border="">
<tr>
<td>$count</td>
<td>$name</td>
<td>$age</td>
<td>$email</td>
<td>$dob</td>
</tr>
</table> ';
$count++;
}
?>
<form id="form1" name="form1" method="post" action="add.php">
<input type="submit" name="Add" id="Add" value="Add" />
<input type="submit" name="Remove" id="Remove" value="Remove" />
<input type="submit" name="Edit" id="Edit" value="Edit" />
</form>
</body>
</html>
这是我尝试过的,也从 mysql 数据库中检索了数据,但无法在我的 html 表上显示它。上面的代码除了在表格上显示值外,什么都做。检查将值打印到表中的 while 循环