Home > Backend Development > PHP Tutorial > The best way to arrange data into N columns per row in a Table_PHP Tutorial

The best way to arrange data into N columns per row in a Table_PHP Tutorial

WBOY
Release: 2016-07-13 17:25:56
Original
906 people have browsed it

When I was writing a program today, I encountered a problem: how to display the data taken out from the database in the format of 2 columns per row
. I think of an article I saw here - "Tricks about %", which not only solves the
problem very simply, but also extends each row of 2 columns to N columns:

For example: $n is 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)."";
}
?>
......

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532009.htmlTechArticleWhen I was writing a program today, I encountered a problem: How to retrieve data from the database by 2 per row The column format is displayed. I think of an article I saw here - "Guan...
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