Hi,

I just created a Drupal site for my laboratory. We would like to have a page that is populated by a SQL query on a backend MySql DB. We may need several such pages that return different queries in tabular format.

Can someone please advise on how is the proper/best way to do this.

Since I'm a newbie to Drupal, detailed instructions will be appreciated :)

Thanks

Arjun

Comments

sun’s picture

What do you mean by "a page that is populated by a SQL query on a backend MySql DB" exactly?
Do you want to display a SQL query when you access a particular url?

Daniel F. Kudwien
unleashed mind

Daniel 'sun' Kudwien
makers99

arjunrn’s picture

What I meant was: We need a page on the website where some of the data displayed is produced by an SQL query on a backend DB (this may even be the same DB as the drupal DB). This data needs to be displayed in tabular format - in a (html) table.

Further on this, we would also like to have a form page where I can insert data into some tables, the same tables where we get the data to show on the page I described above.

Thanks

Arjun

markj’s picture

criznach’s picture

A quick and dirty way would be to put php code right in a page node's content. Look at the database API for db_query, etc... You can execute a query, fetch results, and build a table from page body field. You could probably do it without even using the druapl api if you know basic php/mysql, but I'm not sure if drupal would care if you switched the open database connection. That's where the article posted above comes in...

arjunrn’s picture

Ok Thanks. I'll look at that.

On the same topic, someone had mentioned (to an earlier similar question of mine) that I could to this with something called "custom nodes" and a "view.module" ..... can you let me know exactly what this means. I saw that there were a lot of "node" related modules in the user contributed modules listed for Drupal. Which one should I use ?

Thanks

criznach’s picture

I've used the CCK and views modules together on one project. This allows you to create custom node types with whatever fields you want. You can then use views to generate a paged listing. You can also use the existing content interface to add and update those nodes. Probably not as efficient as a standalone database table, but for small internal stuff, it would probably work nicely. You couldn't do complex queries, (not that I've seen, anyway) but you can do sorting, tagging, filtering, etc...

The contemplate module is also nice for styling the views once you've created them.

Later,
Chris.