Most people use PHP and MySQL together and there are several reasons to do so: It’s easy, fast and powerful! If you create a MySQL database result, the data is not formatted and looks ugly. The following functions or code examples will help you to create better looking MySQL database result pages.
Present a database result in columns
Presenting data into rows or columns is a standard action realized with a simple loop through your record set. Often the data have to be presented in a different order. This example shows a table where the results are provided into columns and rows. Each row holds a number of records from your database; if the number of columns is reached a new row will be used. If there are no more records empty cells will be created and the dynamic creation of cells and rows is ended after the last row has reached the maximum number of columns. Check our PHP Nested Loop Demo.
Show database rows in different colors
Paginate your MySQL database result
Use this small function to create page links for your MySQL database result set. This PHP function is all you need to create forward / backward links (paging) for the records in a database result set. The setup is very easy, just call the function at the place where the links to have appear. Then create a variable for the current limit inside your SQL and create a variable with the total number of records in your result set. The function takes care about an existing query string and creates the whole html code you need for the page navigation.
One thought on “3 methods to tweak your MySQL database result pages”
Thanks for sharing, is there an easy way to combine the function for the vertical arranged result set with the colored rows?
Comments are closed.