The best way to place data into N columns per row in a Table

Source: Internet
Author: User
When I was writing a program today, I encountered a problem: how to display the data retrieved from the database in the format of two columns per row. I think of the article "tips on %" that I saw here not only solved the problem very easily, but also extended 2 columns per row to N columns: for example: $ n is Integer ?. SyntaxHighlighter. all ();

When I was writing a program today, I encountered a problem: how to format the data retrieved from the database in two columns per row
Displayed. I think of an article I have seen here-"tips on %", which not only solves this problem very simply.
Problem, but also expand 2 columns in each row to N columns:

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.