dim j,row_num
j=1
row_num=2
response.write "<table>"
do while not rs.eof
if (j mod row_num)=1 then
response.write "<tr>"
end if
response.write "<td>"&rs("id")&"</td>"
if (j mod row_num)=0 then
response.write "</tr>"
end if
j=j+1
rs.movenext
loop
response.write "</tr>"
response.write "</table>"
%>
j=1
row_num=2
response.write "<table>"
do while not rs.eof
if (j mod row_num)=1 then
response.write "<tr>"
end if
response.write "<td>"&rs("id")&"</td>"
if (j mod row_num)=0 then
response.write "</tr>"
end if
j=j+1
rs.movenext
loop
response.write "</tr>"
response.write "</table>"
%>
谢谢
怎么感觉是ASP的呢?我想请教一下PHP怎么来写?
$res=mysql_query("select ...");
$num=mysql_num_rows($res);//总数
if($num=="0"){
echo"没有结果";
exit;
}
$row="2";//每行显示数
$lines=ceil($num/$row);//行数
for($i="1";$i<=$lines;$i++){
echo"<tr>";
for($j=$row*($i-1);$j<=max($row*$i-1,$num-1);$j++){
$r=mysql_fetch_array($res);
echo"<td>";
echo $r["data"];//读数据
echo"</td>";
}
echo"</tr>";
}
?>
$res=mysql_query("select * from m_reply");
$num=mysql_num_rows($res);//总数
$num="10";
if($num=="0"){
echo"没有结果";
exit;
}
$row="2";//每行显示数
$i="0";
echo"<table width=500 border=1>";
while($r=mysql_fetch_array($res)){
if($i%$row=="0"){
if($i=="0"){
echo"<tr>";
}
else{
echo"</tr><tr>";
}
}
$i++;
//输出数据
echo"<td>";
echo $r["gname"];//数据
echo"</td>";
}
echo"<tr>";
echo"</table>";
?>也可以这样
require("config.php");
if($page==""){$page=1;}
if($t_page==""){$t_page=1;}
$user_array=file($user_file);
$usercount=count($user_array);
$user_all=$usercount-1;
$user_row=$user_all+$page_max-$page*$page_max; //当前成员的行数(初始值)
$user_bottom=$user_all-$page*$page_max; //本页显示的最后一个成员资料
while (($user_row > $user_bottom) and ($user_row > 0)){
list($name,$pwd,$email,$tel)=explode("|",$user_array[$user_row]);
echo "<table border='0' width='100%'>
<tr>
<td><a href=user.php?name=$name>$name</td>
</tr>
</table>";
if ($usercount <= 0){break;} //显示完最后一位成员资料时终止。
$user_row--;
}
?>
thanks!上面是我有文本库写的一个把会员名字都列出来的代码,
怎么实现我上述要求呢?
让每行出两个表格,每个表格里有一个人名
list($name,$pwd,$email,$tel)=explode("|",$user_array[$user_row]);
echo "<table border='0' width='50%' align=left>
<tr>
<td><a href=user.php?name=$name>$name</td>
</tr>
</table>";
if ($usercount <= 0){break;} //显示完最后一位成员资料时终止。
$user_row--; if($user_row==0) break;
list($name,$pwd,$email,$tel)=explode("|",$user_array[$user_row]);
echo "<table border='0' width='50%'>
<tr>
<td><a href=user.php?name=$name>$name</td>
</tr>
</table>";
if ($usercount <= 0){break;} //显示完最后一位成员资料时终止。
$user_row--;
}