我想循环下面表格,而且随意我怎么控制,我这样写不知道对不对?请PHPER达人帮解决一下....稍后给分..(在线等)<table width="531" border="0" cellspacing="0" cellpadding="0">
<?php
if ($i=1)
echo "<tr>";
?>
<?php
end if;
?>
<td width="267" height="178" bgcolor="#FFFFFF">
<table width="267" height="121" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="125" rowspan="4" align="center"><img width="118" height="111"></td>
<td width="142" align="left">视频名称:<span class="SParrow"><?php
$result = mysql_query('select * from news_info where classID=1 order by up_time desc');
$row = mysql_fetch_object($result);
$str = $row->title;
$maxlen = 10;
if (strlen($str)>$maxlen)
{
$str = substr($str, 0,$maxlen-1) . '...';
}
echo '<a href="SPinPlay.php?NID='.$row->NID.'"target="_blank">' . $str . '</a><br>';
$row = mysql_fetch_object($result);
?>
</span></td>
</tr>
<tr>
<td align="left">创建者:<?php
$result = mysql_query("select * from news_info where classID=1 order by up_time desc");
$row = mysql_fetch_object($result);
echo "$row->up_user";
?></td>
</tr>
<tr>
<td align="left">上传于:<span class="SPMainTitle"><?php
$result = mysql_query('select * from news_info where classID=1 order by up_time desc');
$row = mysql_fetch_object($result);
$str = $row->up_time;
$maxlen = 12;
if (strlen($str)>$maxlen)
{
$str = substr($str, 0,$maxlen-1) . '...';
}
echo "<font color=red>$str</font>";
$row = mysql_fetch_object($result);
?>
</span></td>
</tr>
<tr>
<td align="left"><?php echo "<font color=#325791>最新专辑</font>";?></td>
</tr>
</table>
</td>
<?php
$i=$i+1;
if ($i>2)
echo "</tr>";
$i=1;
end if;
?>
</table>
<?php
if ($i=1)
echo "<tr>";
?>
<?php
end if;
?>
<td width="267" height="178" bgcolor="#FFFFFF">
<table width="267" height="121" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="125" rowspan="4" align="center"><img width="118" height="111"></td>
<td width="142" align="left">视频名称:<span class="SParrow"><?php
$result = mysql_query('select * from news_info where classID=1 order by up_time desc');
$row = mysql_fetch_object($result);
$str = $row->title;
$maxlen = 10;
if (strlen($str)>$maxlen)
{
$str = substr($str, 0,$maxlen-1) . '...';
}
echo '<a href="SPinPlay.php?NID='.$row->NID.'"target="_blank">' . $str . '</a><br>';
$row = mysql_fetch_object($result);
?>
</span></td>
</tr>
<tr>
<td align="left">创建者:<?php
$result = mysql_query("select * from news_info where classID=1 order by up_time desc");
$row = mysql_fetch_object($result);
echo "$row->up_user";
?></td>
</tr>
<tr>
<td align="left">上传于:<span class="SPMainTitle"><?php
$result = mysql_query('select * from news_info where classID=1 order by up_time desc');
$row = mysql_fetch_object($result);
$str = $row->up_time;
$maxlen = 12;
if (strlen($str)>$maxlen)
{
$str = substr($str, 0,$maxlen-1) . '...';
}
echo "<font color=red>$str</font>";
$row = mysql_fetch_object($result);
?>
</span></td>
</tr>
<tr>
<td align="left"><?php echo "<font color=#325791>最新专辑</font>";?></td>
</tr>
</table>
</td>
<?php
$i=$i+1;
if ($i>2)
echo "</tr>";
$i=1;
end if;
?>
</table>
===>
if ($i==1)
<tr>
<?
$i=0;
while(){
?>
<td>
</td>
<?
if ($i%3)==0;
echo "<tr height=20></tr>";
$i++;
}
?>