如何以表格格式安排

时间:2014-09-11 14:19:19

标签: php html

如何以表格格式排列?我无法以表格格式排列

<?php 
include("database.php");

$fileStorage = '../upload/'; 
$result = mysql_query("SELECT * FROM upload ORDER By no DESC limit 10") or die(mysql_error()); 

if (mysql_num_rows($result) > 0) { 
    while ($row = mysql_fetch_assoc($result)) { 
    <table>
    <tr>
    <td>echo $row['no'];</td>
   <td> echo $row['title'];</td>
        <td>echo '<a href="'. $fileStorage . $row['file'] .'" target="_blank">'. htmlentities('Click Here', ENT_COMPAT, 'UTF-8') .'</a><br />';</td></tr></table>
    } 
}
?>

1 个答案:

答案 0 :(得分:0)

用这段代码替换你的周期:

if (mysql_num_rows($result) > 0) {
    echo "<table>";
    while ($row = mysql_fetch_assoc($result)) {
        echo "<tr>";
        echo "<td>" . $row['no'] . "</td>";
        echo "<td>" . $row['title'] . "</td>";
        echo '<td><a href="' . $fileStorage . $row['file'] . '" target="_blank">' . htmlentities('Click Here', ENT_COMPAT, 'UTF-8') . '</a></td>';
        echo "</tr>";
    }
    echo "</table>";
}