[英]formatting html page output using css and php
I write out a list of available players to my html page--however my list is almost 65 players long. 我在html页面上列出了可用的播放器列表,但是我的列表将近65个播放器。 I split the html page out using the following css
我使用以下css将html页面分开
#right_side {
float: right;
margin: 20px 0px 20px 0px;
width: 500px;
height: 675px;
border: 1px solid #CCCCCC;
font-family: italic;
}
the PHP code loops through the list in the following way: PHP代码以下列方式遍历列表:
while($row = mysql_fetch_array($result)){
echo "<li>".$row['FirstName'] . " " . $row['LastName']."</li>";
echo"<br>";
}
How do I break up the results so they are into 3 columns of 20 instead of one column of 60? 如何将结果分成三列,每列20个,而不是一列60个?
Add the following css 添加以下CSS
li
{
display:inline-block;
width:30%;
}
This will give you 这会给你
1 | 1 | 2 |
2 | 3
3
4 | 4 | 5 |
5 | 6
6
etc 等等
See it here: http://jsfiddle.net/cmw7T/ 在这里查看: http : //jsfiddle.net/cmw7T/
try this one 试试这个
php 的PHP
$total_num_each_column = mysql_num_rows($result) / 3;
$count = 0;
echo "<ul id='box'>";
while($row = mysql_fetch_array($result)){
if($count > $total_num_each_column) {
echo "</ul> <ul id='box'>";
}
echo "<li>".$row['FirstName'] . " " . $row['LastName']."</li>";
if($count > $total_num_each_column) {
echo "</ul>";
}
$count++;
}
css 的CSS
#box {
float:left;
margin-left:10px;
}
I hope it helps. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.