Empty spaces in phpMyAdmin seems to print out part of the closing table data tag </td>
in my php file. I want to either leave the space blank or have something such as N/A to represent it being empty.
Here is my table display of the users in my php file.
Here is my users table in phpMyAdmin.
Here is my file causing the problem.
<?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
?>
Another question: How can I exclude the ServerAdmin in the displayed table in my php file. I am logged in as a teacher and shouldn't be allowed to change the ServerAdmin's information.
Thanks!