在单个html表中检索两个数据库表值

时间:2011-03-17 07:16:45

标签: html

我的数据库(probe_config)中有一个表(webmeasurementsuite)。我编写了一个php编码,用于从数据库中检索数据并将其显示在html表中。任何人都可以更正我的错误。当我加载php时页面到浏览器,我得到一个空白页。

<?php $ con = mysql_connect(“localhost”,“root”,“mysql”);
if(!$ con)
  {
  死('无法连接:'。mysql_error());
  }

mysql_select_db(“my_db”,$ con);

$ result = mysql_query(“SELECT * FROM webmeasurementsuite”);

echo“<table border='1'>

<tr>
<th> {复制{1}}
     </th> {等待{1}}
     <th> {超时{1}}
     </th> {clearcache {1}}
     <th> {名称{1}}
     </th> {WMS {1}}
<th>;

while($ row = mysql_fetch_array($ result))
  {
  echo“</th>”;
  echo“<th>”。 $ row ['replication']。 “</th>”;
  echo“<th>”。 $ row ['wait']。 “</th>”;
  echo“</tr>”。 $ row ['timeout']。 “<tr>”;
  echo“<td>”。 $ row ['clearcache']。 “</td>”;
  echo“<td>”。 $ row ['name']。 “</td>”;
  echo“<td>”。 $ row ['wms']。 “</td>”;
  echo“<td>&gt;”;
  }
echo“</td>”;

mysql_close($ CON);
?&GT;

1 个答案:

答案 0 :(得分:0)

我认为您需要了解有关Web Development的更多信息。

HTML仅用于以适当的格式呈现信息。为了访问数据库记录,我们必须使用服务器端Scripting Languages或Web技术(J2EEJSPASP等)来访问数据库。单独使用HTML无法完成。

如果错了,请再详述一下你的问题。