我在我的网站上制作了一个Tag Cloud类型的交易,当你去看1个标签时
示例:
注意第一行看起来像是间隔2个空格,最后一行是1。
CSS
.tabcontent{
display:none;
}
代码
$tag_movies_result = mysql_query("SELECT * FROM tags WHERE tagname='$n' AND movie > 0");
$total_times_used_movies = mysql_num_rows($tag_movies_result);
<div id="movies" class="tabcontent">
<?php if ($total_times_used_movies > '0') { ?>
<table width="100%">
<tr>
<td>
<?php
while ($row = mysql_fetch_array($tag_movies_result))
{
$movies_to_tag_result = mysql_query("SELECT * FROM movies WHERE id=".$row['movie']." ORDER BY name ASC");
while ($row = mysql_fetch_array($movies_to_tag_result))
{
?>
<a href="./movie.php?id=<?php echo $row['id']; ?>" title="<?php echo $row['name']; ?> (<?php echo $row['year']; ?>)"><img src="./images/movies/<?php echo $row['id']; ?>.jpg" width="150" height="150" border="0" alt="<?php echo $row['name']; ?>" /></a>
<?php } } ?>
</td>
</tr>
</table>
<?php }else{ ?>
NO MOVIES WITH THIS TAG.
<?php } ?>
</div>
在此页http://i51.tinypic.com/ncms9c.png上,它使用相同的确切代码并正确显示
答案 0 :(得分:1)
我认为最简单的解决方案是完全废弃表格,将所有<td>
转换为<div>
,然后只给它们float:left;
。对于这个演示,我只是将CSS内联,但是当你开始工作时,你会想把它放在CSS文件中。
<div id="movies">
<?php if ($total_times_used_movies > '0'): ?>
<!-- Also add css to set the width to 25% of 'movies' width, including borders, margins, padding, etc -->
<div style="float:left;">
<?php
while ($row = mysql_fetch_array($tag_movies_result)):
$movies_to_tag_result = mysql_query("SELECT * FROM movies WHERE id=".$row['movie']." ORDER BY name ASC");
while ($row = mysql_fetch_array($movies_to_tag_result)):
?>
<a href="./movie.php?id=<?php echo $row['id']; ?>" title="<?php echo $row['name']; ?> (<?php echo $row['year']; ?>)"><img src="./images/movies/<?php echo $row['id']; ?>.jpg" width="150" height="150" border="0" alt="<?php echo $row['name']; ?>" /></a>
<?php
endwhile; // movies to tag result
endwhile; // tag movies result
?>
</div>
<?php else: ?>
NO MOVIES WITH THIS TAG.
<?php endif; ?>
</div>
<!-- END movies -->