<!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循環打印值表從sql數據庫插入值到html表
已打印每次在行值進行一些修改。一旦檢查
$sql
查詢得到的行?? – Gautam3164對於1表單1提交按鈕是足夠的,否則動作將是相同的所有他們,但isset不同() – Fabio
需要的評論:mysql_被棄用,你應該使用mysqli_ ...但除此之外,它打印空行,還是基本上返回零結果? –