My task is to take data from different databases in different server and to display them in a single web page.I am working in joomla and i am able to take data from the databases using separate queries for each database.But the problem is that i need to give sorting and pagination to this web page. how can i do this without making any performance issue since all the databases contains a lot of data. Or can i use a single sql query for this ??
-
you can make use of LIMIT and OFFSET to make pagination,Ibu– Ibu2011-05-13 04:00:17 +00:00Commented May 13, 2011 at 4:00
-
first you need to decide how many result you want per page, and you can make the calculation on how much to offset for each pageIbu– Ibu2011-05-13 04:01:24 +00:00Commented May 13, 2011 at 4:01
-
did you get a solution for this? @anuja12h-rai– h-rai2016-10-27 23:50:03 +00:00Commented Oct 27, 2016 at 23:50
2 Answers
To do what you're describing in Joomla I would recommend the Fabrik extension. It lets you create fairly complex front-end visualizations and table views of database data, as well as search forms and single-page table views that have nice ordering/sorting/per-column filtering controls.
More importantly, Fabrik lets you set up connections to multiple databases. Once you've set up all your database connections in Fabrik, you can then import and configure those tables in the Fabrik back-end, and after that they are all treated the same by the other parts of the administrative interface.
In other words, you can create front-end table views or search forms in the Fabrik back-end, which can do things like table joins across multiple database connections, or pre-filter result sets of a table from one database using data stored in another database (among other things) and Fabrik will take care of creating and closing the necessary database connections for you.
Comments
You can use a GET parameter to use pass the page that you want to view, and the offset will be calculated from that.
$page = (isset($_GET['page']))? (int)$_GET['page']: 1;
$per_page = 25;
$offset = ($page-1) * $per_page; // you will have to improve this
$sql = "SELECT * FROM table
WHERE (condition)
LIMIT {$offset},{$per_page}";
$result = mysql_query($sql) or die('Error : '.mysql_error());
You will have to integrate it with your code, to make it work better of course.