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)."";
}
?>
......