Home > Backend Development > PHP Tutorial > 如何在Table中将数据摆放成每行N列的最佳方法_PHP

如何在Table中将数据摆放成每行N列的最佳方法_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 12:38:19
Original
820 people have browsed it

今天在写程序的时候遇到一个问题如何将从数据库中取出的数据按每行2列的格式

显示出来。我联想到在此曾看到的一篇文章——“关于
%的技巧”不仅非常简单地解决了

问题
而还且将每行2列扩展到N列



例如
$n为Integer

?>

......

$sql
="select id,subject from new ";



ora_parse
($cursor,$sql);

ora_exec
($cursor);

$i
=0;



while(ora_fetch($cursor))

{

$i
++;

if ($i%$n==1)

{

echo ""

echo "".ora_getcolumn($cursor,1)." ";

}

elseif ($i%$n==0)

{

echo "".ora_getcolumn($cursor,1)." ";

echo " "
;

}

else

echo "

".ora_getcolumn($cursor,1)." ";

}

?>

......
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template