作者NUKnigel (简简单单)
看板PHP
标题[请益] php & xhtml
时间Sun Dec 17 12:45:33 2006
今天第一次碰php & mysql
但刚刚忙了一个早上
发现如果用xhtml的方法来表示 table
会无法显示 @@
但是一改成html就成功显示...
是我的方法错误...还是php 和 xhtml本来就不相容呢?
code
-----------------------------
<?php
$link = mysql_pconnect("localhost", "xxxxxx", "");
mysql_select_db("shopping") or die("无法选择资料库");
$query = "SELECT * FROM product";
$result = mysql_query($query) or die("无法送出" . mysql_error( ));
echo "<table summary="教师资料">";
echo "<colgroup span="1"></colgroup>";
echo "<colgroup span="2"></colgroup>";
echo "<colgroup span="3"></colgroup>";
echo "<colgroup span="4"></colgroup>";
echo "<colgroup span="5"></colgroup>";
echo "<colgroup span="6"></colgroup>";
echo "<thead>";
echo "<tr>";
echo "<th scope="col">product_id</th>";
echo "<th scope="col">product_name</th>";
echo "<th scope="col">price</th>";
echo "<th scope="col">category</th>";
echo "<th scope="col">product_family</th>";
echo "<th scope="col">product_class</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ( $row = mysql_fetch_array($result) ){
echo "<tr>";
echo "<td scope="row">".$row['product_id']."</td>";
echo "<td scope="row">".$row['product_name']."</td>";
echo "<td scope="row">".$row['price']."</td>";
echo "<td scope="row">".$row['category']."</td>";
echo "<td scope="row">".$row['product_family']."</td>";
echo "<td scope="row">".$row['product_class']."</td>";
echo "</tr>";
}
echo "</tbody></table>";
mysql_free_result($result);
?>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.172.78.11
1F:推 mathfeel:xhtml的话要valid xml吧?header和其他部分呢? 12/17 13:31