<?php
echo '<table border="1">';
for($i=0;$i<10;$i++){
if($i%2==0) echo '<tr>';
echo '<td>'.$i.'</td>';
if($i%2==1) echo '</tr>';
}
echo '</table>';
?>
echo '<table border="1">';
for($i=0;$i<10;$i++){
if($i%2==0) echo '<tr>';
echo '<td>'.$i.'</td>';
if($i%2==1) echo '</tr>';
}
echo '</table>';
?>
解决方案 »
- PHP在保留样式的前提下编辑WORD模板
- 求一个上传FLASH文件的实例!谢谢各位大侠!小弟拜谢!
- 有关php的错误
- php: openssl_public_encrypt()和openssl_private_encrypt()返回值总是FALSE
- 自己写的一个soap,怎么都不对,请牛人帮帮忙了
- php 生成图片。中文显示乱码
- apache安装后运行正常,为什么在此服务下网页打不开
- PHP cURL并发里的callback那行是什么功能?
- mail()的函数
- mkdir ./创建成功 /无法创建 thinkphp
- 为何说BCDIV未定义
- 在windows里怎么上传文件呀PHP.INI怎么设制呀
$result_ncbookname = mysql_query($query_ncbookname) or die(mysql_error());
$i=2;//这里改动
while($arr_ncbookname = mysql_fetch_array($result_ncbookname))
{
$strbook .="<td width=\"50%\">·<a href=\"more_fenlei.php?nclassid=$arr_ncbookname[nclassid]&anclassid=$arr_ncbookname[anclassid]&btype=$btype&ptype=$arr_ncbookname[nclass]\">".$arr_ncbookname[nclass]."</a></td>";
if($i%2 == 0)
{
echo "<table width=\"101%\" border=\"0\"><tr>$strbook</tr></table>";
$strbook = "";
}
$i++;
}试试!!
$row = 2;
$strbook = "<table width=\"101%\" border=\"0\">"; while($arr_ncbookname = mysql_fetch_array($result_ncbookname))
{
if ( $i == 0 )
{
$strbook .= "<tr>";
}
$strbook .="<td width=\"50%\">·<a href=\"more_fenlei.php?nclassid=$arr_ncbookname[nclassid]&anclassid=$arr_ncbookname[anclassid]&btype=$btype&ptype=$arr_ncbookname[nclass]\">".$arr_ncbookname[nclass]."</a></td>";
if($i == $row-1)
{
$strbook .= "</tr>";
$i = 0;
}
else
$i++;
}
$str .= "</table>";
$result_ncbookname = mysql_query($query_ncbookname) or die(mysql_error());
$i=0;
while($arr_ncbookname = mysql_fetch_array($result_ncbookname))
{
$strbook ="<td width=\"50%\">·<a href=\"more_fenlei.php?nclassid=$arr_ncbookname[nclassid]&anclassid=$arr_ncbookname[anclassid]&btype=$btype&ptype=$arr_ncbookname[nclass]\">".$arr_ncbookname[nclass]."</a></td>";
if($i%2 == 0) echo "<table width=\"101%\" border=\"0\"><tr>';
echo $strbook;
if($i%2==1) echo "</tr></table>";
$i++;
}
2、你可能需要的是这样的格式
·经典译丛 ·影印教材
·会计 ·经济学
·管理学 ·金融
·贸易 ·财政
·物流管理 ·项目管理
·营销管理 ·电子商务
·考试丛书 ·励志图书
·保险
如果是,可把$i++;放在if($i%2 == 0)前面。写成
$i++;
if($i%2 == 0) {
echo "<table width=\"101%\" border=\"0\"><tr>$strbook</tr></table>";
$strbook = "";
}