Html 如何将数据库表列表显示到URL?

Html 如何将数据库表列表显示到URL?,html,mysql,hyperlink,html-table,Html,Mysql,Hyperlink,Html Table,我们希望显示数据库“X”中一个表的列表链接。 这是我的密码: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>database connections</title> </head> <body> <?php $username = "root"; $password = "mysql

我们希望显示数据库“X”中一个表的列表链接。 这是我的密码:

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>database connections</title>
</head>
<body>
  <?php
  $username = "root";
  $password = "mysql";
  $host = "localhost";

  $connector = mysql_connect($host,$username,$password)
      or die("Unable to connect");
    echo "Connections are made successfully::";
  $selected = mysql_select_db("nentholbenin", $connector)
    or die("Unable to connect");

  //execute the SQL query and return records
  $result = mysql_query("SELECT * FROM utilisateurs "); 
  ?>
  <table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;" >
  <thead>
    <tr>
      <th>Categories</th>
    </tr>
  </thead>
  <tbody>
    <?php 

      $db_result = mysql_query("SELECT Categories FROM utilisateurs"); 
      $result = $db_result; echo '<ul>';

      foreach($array as $index => $db_result){
       echo '<li><a href=".'$db_result['Categories'].'"</a></li>';
       }
       echo '</ul>';
    ?>
  </tbody>
</table>
 <?php mysql_close($connector); ?>
</body>
</html>
我得到这个错误:

分析错误:语法错误,意外的“$db_result”T_变量, 期待“,”或“;”在

试试这个:

 <?php 

          $db_result = mysql_query("SELECT Categories FROM utilisateurs"); 
          $result = $db_result; echo '<ul>';

          foreach($array as $index => $db_result){
           echo '<li><a href="'.$db_result['Categories'].'"</a></li>';
           }
           echo '</ul>';
    ?>

您在$db_结果之前忘记了点。 使用mysql\u查询执行查询后,无法直接获取数据。使用mysql\u fetch\u数组或mysql\u fetch\u assoc

试试下面的代码

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>database connections</title>
    </head>
    <body>
      <?php
      $username = "root";
      $password = "mysql";
      $host = "localhost";

      $connector = mysql_connect($host,$username,$password)
      or die("Unable to connect");
        echo "Connections are made successfully::";
      $selected = mysql_select_db("nentholbenin", $connector)
      or die("Unable to connect");

      //execute the SQL query and return records
      $result = mysql_query("SELECT * FROM utilisateurs "); 
      ?>
    <table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;" >
        <thead>
        <tr>
            <th>Categories</th>
        </tr>
        </thead>
        <tbody>
        <?php

        $db_result = mysql_query("SELECT Categories FROM utilisateurs");
        $result = $db_result; echo '<ul>';

         while($array = mysql_fetch_assoc($result)) {
         echo '<li><a 
 href="/'.$array['Categories'].'">'.$array['Categories'].'</a></li>';
           }
        echo '</ul>';
        ?>
        </tbody>
    </table>
    <?php mysql_close($connector); ?>
    </body>
    </html>

圆点应该在“.$db_结果['Categories']”之后。谢谢Sunny!但我得到了这个错误警告:为foreach工作提供的参数无效!但是项目类别链接不显示,只显示标签类别。我想做的是链接从用户链接到帖子的类别和子类别。因此,如果用户选择“分类”,则可以显示其中的所有列表链接。@nEntholdDigital锚定标记未正确关闭,我已更新了答案。