好的,我知道有人问过这个问题,但我觉得我的情况有点不同和独特。我将我的 php 和 html 代码合并在一起,它正在制作一张 9 张图片而不是 3 x 3 长的表格。如果有人愿意帮助我,这也是一个次要问题,我希望将所有图片格式化为相同大小使表格看起来更好任何帮助表示赞赏。
这是我的表格文件
<?php 
// Get our database connector
require("includes/conn.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <div>
        <?php   
            // Grab the data from our people table
            $sql = "select filename from people LIMIT 9";
            $result = mysql_query($sql) or die ("Could not access DB: " . mysql_error());
            $count = mysql_num_rows(result);
            $i = 0;
            $per_row = 3;
            echo '<table><tr>';
            while ($row = mysql_fetch_assoc($result))
            {
            echo "<td><img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br /></td>";
            if(++$i % $per_row == 0 && $i > 0 && $i < $count) {
                # Close the row
                echo '</tr><tr>';
                }
        }
            for($x = 0; $x < $per_row - $i % $per_row; $x++) {
             echo '<td></td>';
            }
            echo '</tr></table>';
        ?>
    </div>
</body>