PHP Classes
elePHPant
Icontem

Report: Show MySQL results in pages updated using AJAX

Recommend this page to a friend!
  Info   View files View files (16)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2010-02-09 (6 years ago) RSS 2.0 feedNot enough user ratingsTotal: 1,098 This week: 1All time: 3,298 This week: 1,047Up
Version License PHP version Categories
blue-report-class 1.0GNU General Publi...3.0HTML, Databases
Description Author

This class can be used to show MySQL query results in pages with browse links updated using AJAX to avoid page reloading.

It can execute a given MySQL query and display the results in an HTML table.

The table may have headers with links that sort the results when they are clicked.

The listing may also be split in multiple pages with a limited number of result rows. Pagination links are display to let the user browse other query result pages.

AJAX requests are sent to retrieve new pages of results when either the sorting or pagination links are clicked to avoid full page reloading.

Picture of kai
Name: kai <contact>
Classes: 2 packages by
Country: South Africa South Africa

Details
 

Please run testData.sql against a database and change the example files to point to that database to view the examples.


 

1 CONSTRUCTION


call __Construct($query,$interval) to create the report with the query you want and the number of records on a page

or __Construct($query) with all records on the page

or __Construct($query,"",$order,$direction)
   __Construct($query,$interval,$order,$direction) to order your report by default on a column


$query is the mysql query the class will use to generate your report
$order is the name of a column in the database you want to order by
$direction can be ASC or DESC

 

 

2 ADDING FIELDS TO THE REPORT


2.1 adding a normal field


call

addDisplayField($name,$display,$sizeOfField)

or addDisplayField($name,$display)


$name is the name of the field in the databases and must be in the query you constructed with

$display is the heading of the field displayed to the user

$sizeOfField is the minimum width or the table column for this field


 

2.2 adding a special field


here you can create a field with special attributes, eg. a link field or running javascripts on the field


call

addSpecialDisplayField($name,$display,$text,$sizeOfField=50)

or addSpecialDisplayField($name,$display,$text,$sizeOfField=50)


$name is the name of the field in the database. this is only used for sorting purposes. if the user sorts on this field this field in the database will be used.

$display is the heading of the field displayed to the user

$text this is the special text that will be used as the field, anything in {} will be replaced by a field in the database eg. if name is a field in the database use <a href="javascript:alert('you clicked on {name}')">{name}</a>

$sizeOfField is the minimum width or the table column for this field


 

 

 

3 ENABLING AJAX


This allows the report to refreshes its data, when a link is clicked on the navigation bar, or when sorting on a column, without refreshing the entire page.

(Not recommended for pages that requires search engine friendliness)


call enableAjax($database_host,$database_user,$database_password,$database_name)


the database details is required when data is refreshed


4 SETTING THE LOOK AND FEEL


all the following methods are optional


 

enableNavigationalNumbers($variance)

call to show page numbers on the navigation that can be used as links

$variance is the number of pages shown from the current page in both directions



setAjaxLoadingText($text)
The text that displays while data is refreshed with ajax





getNumberOfResultsSelectorGoLink($text)
getNumberOfResultsPerPageSelector($interval,$maximum)

these should be used together
getNumberOfResultsSelectorGoLink gets a selector for the user to select the number of records he wants per page
getNumberOfResultsPerPageSelector gets a link to click to refresh the data according to the above selection

$text will be displayed as the link
$interval in the selection every <$interval>the number will be displayed eg $interval=10 then 10,20,30 will be the options
$maximum the maximum number of records the user can choose from.




setLeftImage($loc)

Call to set an image to be used as the "previous page" link


setRightImage($loc)

Call to set an image to be used as the "next page" link


setLeftJumpImage($loc)

Call to set an image to be used as the "first page" link


setRightJumpImage($loc)

Call to set an image to be used as the "last page" link


 

setLeftText($text)

Call to set text to be used as the "previous page" link


setRightText($text)

Call to set text to be used as the "next page" link


function setLeftJumpText($text)

Call to set text to be used as the "first page" link


setRightJumpText($text)

Call to set text to be used as the "last page" link


 

setSortASCPicture($loc)

Call to set an image displayed with a column heading when that column is sorted ascending


setSortDESCPicture($loc)

Call to set an image displayed with a column heading when that column is sorted descending


 

setTableClassName($name)

sets the css-class of the table that contains the data


setNavigationTableClassName($name)

sets the css-class of the table that contains the navigation links


setSortLinkClassName($name)

sets the css-class of a link that orders the data on a column


setNavigationLinkClass($name)

sets the css-class of the navigation links

  Files folder image Files  
File Role Description
Plain text file report.php Class main class
Accessible without login Plain text file AjaxExample.php Example example
Accessible without login Plain text file AjaxExampleNoNavigation.php Example example
Accessible without login Plain text file AjaxExampleNoNavigationPages.php Example example
Accessible without login Plain text file AjaxExampleNoNavig...ResultsSelector.php Example example
Accessible without login Plain text file AjaxExampleWithNum...ResultsSelector.php Example example
Accessible without login Plain text file Description.txt Data description
Accessible without login Plain text file normalExample.php Example example
Accessible without login Plain text file normalExampleNoNavigation.php Example example
Accessible without login Plain text file NormalExampleNoNavigationPages.php Example example
Accessible without login Plain text file NormalExampleNoNav...ResultsSelector.php Example example
Accessible without login Plain text file NormalExampleWIthN...ResultsSelector.php Example example
Accessible without login Plain text file Readme.txt Doc. readme
Accessible without login Image file sortdown.png Icon for example pages
Accessible without login Image file sortup.png Icon for example pages
Accessible without login Plain text file testData.sql Data example data

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,098
This week:1
All time:3,298
This week:1,047Up
User Comments (1)
Not so great.
6 years ago (Hariram)
30%StarStar