phpMyAdmin中的空格似乎打印出我的php文件中关闭表数据标记</td>
的一部分。我想把空格留空或者用N / A这样的东西来表示它是空的。
这是我的php文件中的table display of the users。
这是phpMyAdmin中的users table。
这是导致问题的文件。
<?php
mysql_connect('localhost','root','');
mysql_select_db('project');
if (isset($_POST['update'])){
$UpdateQuery = "UPDATE users SET id='$_POST[id]', username='$_POST[username]', password='$_POST[password]', first_name='$_POST[first_name]', last_name='$_POST[last_name]', email='$_POST[email]'
WHERE id='$_POST[hidden]'";
mysql_query($UpdateQuery, mysql_connect('localhost','root',''));
};
if (isset($_POST['delete'])){
$DeleteQuery = "DELETE FROM users WHERE id='$_POST[hidden]'";
mysql_query($DeleteQuery, mysql_connect('localhost','root',''));
};
if (isset($_POST['add'])){
$AddQuery = "INSERT INTO users (id, username) VALUES ('$_POST[uid]','$_POST[uusername]','$_POST[upassword]','$_POST[ufirst_name]','$_POST[ulast_name]','$_POST[uemail]')";
mysql_query($AddQuery, mysql_connect('localhost','root',''));
};
$sql = "SELECT * FROM users";
$records = mysql_query($sql);
//session_start();
//if(!isset($_SESSION["id"])){
// header("location:main.html");
//} else {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Table Display (Allows instructor to add students, delete, and update id and names)
</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<table width="25%" border="1" cellpadding="1" cellspacing="1" align="center">
<tr>
<th>ID</th>
<th>Username</th>
<th>Password</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th></th>
<th></th>
<th></th>
</tr>
<?php
while ($users = mysql_fetch_assoc($records)) {
echo "<form action=displayusers.php method=post>";
echo "<tr>";
echo "<td>"."<input type=text name=id value=".$users['id']." </td>";
echo "<td>"."<input type=text name=username value=".$users['username']." </td>";
echo "<td>"."<input type=text name=password value=".$users['password']." </td>";
echo "<td>"."<input type=text name=first_name value=".$users['first_name']." </td>";
echo "<td>"."<input type=text name=last_name value=".$users['last_name']." </td>";
echo "<td>"."<input type=text name=email value=".$users['email']." </td>";
echo "<td>"."<input type=hidden name=hidden value=".$users['id']." </td>";
echo "<td>"."<input type=submit name=update value=Update"." </td>";
echo "<td>"."<input type=submit name=delete value=Delete"." </td>";
echo "</tr>";
echo "</form>";
}//end while
echo "<form action=displayusers.php method=post>";
echo "<tr>";
echo "<td><input type=text name=uid></td>";
echo "<td><input type=text name=uusername></td>";
echo "<td><input type=text name=upassword></td>";
echo "<td><input type=text name=ufirst_name></td>";
echo "<td><input type=text name=ulast_name></td>";
echo "<td><input type=text name=uemail></td>";
echo "<td>"."<input type=submit name=add value=Add"." </td>";
echo "<td>";
echo "<td>";
echo "</form>";
?>
</table>
</body>
</html>
<?php
//} // end else statement
?>
另一个问题:如何在我的php文件中显示的表中排除ServerAdmin。我以教师身份登录,不应该被允许更改ServerAdmin的信息。
谢谢!