Php 在每个表数据中显示列数据

Php 在每个表数据中显示列数据,php,html,sql,sql-server,Php,Html,Sql,Sql Server,假设数据库中有一个表有4列 这是我网站上的表格 如何在每个表数据中显示我的表列数据 有什么建议吗 我只有这些代码,因为我是新的php我只是使用宏媒体的接口 --------------------------------------------------------------------- Quantity | Unit | Detials of Items | ISSUED DATE | RETURNED | | |

假设数据库中有一个表有4列

这是我网站上的表格

如何在每个表数据中显示我的表列数据

有什么建议吗

我只有这些代码,因为我是新的php我只是使用宏媒体的接口

---------------------------------------------------------------------
Quantity  |   Unit  |  Detials of Items |  ISSUED DATE  |  RETURNED |
          |         |                   |               |           |
---------------------------------------------------------------------
tbl col 1 |tbl col2 | tbl col2          |  tbl col 3    | tbl col4  |
---------------------------------------------------------------------
如果您正在使用,哪种方法更好:

$myServer = "server";
 $myUser = "user";
 $myPass = "password";
 $myDB = "mssqldb"; 

 //connection to the database
 $dbhandle = mssql_connect($myServer, $myUser, $myPass)
     or die("Couldn't connect to SQL Server on $myServer"); 

 //select a database to work with
      $selected = mssql_select_db($myDB, $dbhandle)
          or die("Couldn't open database $myDB"); 

 //declare the SQL statement that will query the database
     $query = "SELECT eidnumber ";
     $query .= "FROM tablename ";

<table width="935" height="102" border="1">
      <tr>
        <th width="89" rowspan="2" scope="col">Quantity</th>
        <th width="87" rowspan="2" scope="col">Unit</th>
        <th width="137" rowspan="2" scope="col">Details of Item(s) Accounted </th>
        <th width="221" rowspan="2" scope="col">ISSUED DATE </th>
        <th height="51" colspan="3" scope="col">RETURNED</th>
        <th width="254" rowspan="2" scope="col">
    <p>REMARKS</p>    </th>
      </tr>
      <tr>
        <th width="24" height="39" scope="col">C</th>
        <th width="18" scope="col">X</th>
        <th width="53" scope="col">DATE</th>
      </tr>
    </table>
    <table width="935" border="1">
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
      <tr>
        <td width="90">&nbsp;</td>
        <td width="86">&nbsp;</td>
        <td width="137">&nbsp;</td>
        <td width="221">&nbsp;</td>
        <td width="24">&nbsp;</td>
        <td width="17">&nbsp;</td>
        <td width="55">&nbsp;</td>
        <td width="253">&nbsp;</td>
      </tr>
    </table>

除了上面的答案,您还可以使用mysqli。下面是一个例子:

echo "<table>";
$sql = mysql_query("SELECT * FROM YOUR_TABLE");
while($row = mysql_fetch_assoc($sql))
{
    echo "
    <tr>
        <td>". $row['quantity'] ."</td>
        <td>". $row['unit'] ."</td>
        <td>". $row['details'] ."</td>
        <td>". $row['issued_date'] ."</td>
        <td>". $row['returned'] ."</td>
    </tr>
    ";
}
echo "/<table>";

@Þaw我编辑了我的帖子sirwell我不是php高手,但我认为你应该做的是在php中创建一个for循环并添加进去,然后从数据库中提取每个数据。@hmxamoghal会做的,先生,谢谢
echo "<table>";
$sql = mysql_query("SELECT * FROM YOUR_TABLE");
while($row = mysql_fetch_assoc($sql))
{
    echo "
    <tr>
        <td>". $row['quantity'] ."</td>
        <td>". $row['unit'] ."</td>
        <td>". $row['details'] ."</td>
        <td>". $row['issued_date'] ."</td>
        <td>". $row['returned'] ."</td>
    </tr>
    ";
}
echo "/<table>";
$result = $mysqli->query($query);
while ($row = $result->fetch_object()){
    echo "<tr>";
    echo "<td>" . $row->quantity . "</td>"
...etc...
}