0

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 ??

3
  • you can make use of LIMIT and OFFSET to make pagination, Commented 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 page Commented May 13, 2011 at 4:01
  • did you get a solution for this? @anuja12 Commented Oct 27, 2016 at 23:50

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

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.

3 Comments

@lbu But i am not using a single sql command,i am using 12 sql queries to take data from 12 different databases.i need to display all the results in a single list
you will still need to use the limit and offset, i wrote it in the most generic way because i have no idea how your db look like, the more detail you provide, the better help you will get. show some of your code
@lbu I have 12 databases and same table is repeating in all these databases.Each database will have like 100 entries every day.i need to combine data in all these 12 tables and display it in a list.I need the list to be updated all the time.the databases are in different server so i don't think that i can use a single sql query.Here i am taking data from the tables using 12 separate queries for each database ,so i cant apply the limit directly to each sql query. i need help in adding pagination and sorting to this complete list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.