gpt4 book ai didi

php - 如何用四列回显两行

转载 作者:行者123 更新时间:2023-11-30 01:00:32 25 4
gpt4 key购买 nike

如何回显两行四列

显示是这样的 http://www.koolfree.com/ImageUpload/uploads/1385306598.jpg

我想要这样 http://www.koolfree.com/ImageUpload/uploads/1385348807.jpg

我该怎么做?请帮我解决这个问题。

<?php
$max_results = 8;


$from = (($page * $max_results) - $max_results);


if(empty($_POST)) {
$query = "SELECT * FROM `noofbuilding` WHERE `buildingname` LIKE '".$letter."%' ORDER BY `buildingname` ASC LIMIT $from, $max_results";
}
$result = mysql_query("SET NAMES utf8"); //the main trick
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);

echo '<div style="width:100%;" algin="center">';
echo "<table border='0' cellpadding='1' width='100%' bordercolor='000099'border='solid'>
";
echo "<tr>";

while($row = mysql_fetch_array($result))
{


echo "<td><div align='center'><img src='images/building_icon.gif' width='90' height='90'></a><p>" . $row['buildingname'] . "</p><div></td>";
}



echo "</tr>";
echo "</table>";
echo '</div>';



// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as buildingname FROM noofbuilding ORDER BY buildingname ASC"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<p class=\"style2\">Pages: ";

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$prev&letter=$letter\" class=\"style2\">Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo " ";
}
}


// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$next&letter=$letter\" class=\"style2\">Next</a>";
}
echo "</p>";

mysql_close();
?>

最佳答案

像下面这样改变你的 while 循环

<table width="100%" border="1" cellspacing="2" cellpadding="2">
<?php
$count=0;
while($row = mysql_fetch_array($result))
{
if($count%4==0)
{
echo "<tr/>";
echo "<tr>";
}

echo "<td><div align='center'><img src='images/building_icon.gif' width='90' height='90'></a><p>" . $row['buildingname'] . "</p><div></td>";

$count++;

}
?>
</table>

关于php - 如何用四列回显两行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20173405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com