【问题标题】:PHP connecting with SQL and displaying dataPHP 连接 SQL 并显示数据
【发布时间】:2013-01-29 23:22:09
【问题描述】:

大家好

我创建(复制)了一个网站,可以查看我的数据库中的信息。但我拥有的代码显示了每个机器人以及成员。

我将它连接到本地主机,数据库是phpbb3。

我需要一个刺痛来摆脱 group_id 为 6 的机器人。

这是我的代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
        <title>View Records</title>
</head>
<body>

<?php
/* 
        VIEW.PHP
        Displays all data from 'phpbb_users' table
*/

        // connect to the database
        include('connect-db.php');

        // get results from database
        $result = mysql_query("SELECT * FROM phpbb_users") 
                or die(mysql_error());  

        // display data in table
        echo "<p><b>View All</b> | <a href='view-paginated.php?page=1'>View Paginated</a></p>";

        echo "<table border='1' cellpadding='10'>";
        echo "<tr> <th>ID</th> <th>Username</th> <th>Email</th> <th></th> <th></th></tr>";

        // loop through results of database query, displaying them in the table
        while($row = mysql_fetch_array( $result )) {

                // echo out the contents of each row into a table
                echo "<tr>";
                echo '<td>' . $row['user_id'] . '</td>';
                echo '<td>' . $row['username'] . '</td>';
                echo '<td>' . $row['user_email'] . '</td>';
                echo '<td><a href="edit.php?id=' . $row['user_id'] . '">Edit</a></td>';
                echo '<td><a href="delete.php?id=' . $row['user_id'] . '">Delete</a></td>';
                echo "</tr>"; 
        } 

        // close table>
        echo "</table>";
?>
<p><a href="new.php">Add a new record</a></p>

</body>
</html> 

谢谢, 高级。

【问题讨论】:

标签: php sql view-helpers


【解决方案1】:

改变这个:

$result = mysql_query("SELECT * FROM phpbb_users")

$result = mysql_query("SELECT * FROM phpbb_users WHERE group_id <> 6")

【讨论】:

  • 感谢您的快速修复!
猜你喜欢
  • 1970-01-01
  • 2022-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多