douchen7555 2016-03-23 18:12
浏览 106

如何在空表数据中显示NULL或N / A.

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)