0

我正在尝试生成一个包含行的表,但我这样做的方式似乎是错误的,它只是为每个项目创建一个表。

if ($favorite_post_ids):
        $favorite_post_ids = array_reverse($favorite_post_ids);
        foreach ($favorite_post_ids as $post_id) {
            $p = get_post($post_id);
            echo "<table width=\"100%\" border=\"5\">\n"; 
            echo "<tr>\n"; 
            echo "<td>" . get_the_post_thumbnail($post_id, array(55,55), array('class' => 'fav-thumbs')) . "</td>\n"; 
            echo "<td><a href='".get_permalink($post_id)."' title='". $p->post_title ."'><span class='fav-title'>" . $p->post_title . "</span></a></td>\n"; 
            echo "<td>";
            wpfp_remove_favorite_link($post_id);
            echo "</td>\n";
            echo "</tr>\n"; 
            echo "</table>\n";

请帮忙。

4

1 回答 1

1

echo "<table width=\"100%\" border=\"5\">\n";//这只需要在foreach之前发生一次。

echo "</table>\n";//这只需要在最后发生一次。

如果您希望页面加载得更快,您想使用某种类型的 $html 变量。(只要您不尝试生成大表。)

于 2012-07-29T05:08:23.763 回答