Hello

I have two different database from which one is of drupal and another is custom application. Custom application is complicated so i can not make module of that.

Now with help of this http://drupal.org/node/18429 i have connected 2 different database at a time.

What i want to know is how can i display those data in one page / my account page ?

here is my basic code which i have written. If any error are there than please help me out. I am stuck here.

<?php

function modulename_menu() {

  $items = array();

  $items['admin/settings/modulename'] = array(
    'title' => ' module settings',
    'description' => 'modulename setting',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('modulename_admin'),
    'access arguments' => array('access modulename pages'),
    'type' => MENU_NORMAL_ITEM,
   );

  $items['modulename'] = array(
    'title' => t('modulename list down data from different database in one page or home page after login'),
    'description' => t('View reports.'),     
    'page callback' => 'automation_view',
    'access callback' => 'user_access',
    'access arguments' => array('access modulename'),
    'type' => MENU_NORMAL_ITEM
   );

  return $items;
}


function modulename_view($node, $teaser = FALSE, $page = FALSE)
{
    global $user;

    db_set_active('another_db');
    $sql = 'SELECT * FROM {another_table} WHERE user_id = '.$user->uid;
    $result = db_query($sql);
    $i =0;
    while ($product = db_fetch_object($result))
    {
        $prod_name[$i] = $product->prod_name;
        $i++;
    }
// at this point i have tried different theme option but might be i am using wrong syntax or method it is not working.

    db_set_active('default');
}
?>


I hope my question is clear in this post. If you have any query regarding this post than let me know i will explain it again.

Thank you.
Tejas Mehta

CommentFileSizeAuthor
#1 test.JPG6.7 KBtejaspmehta

Comments

tejaspmehta’s picture

StatusFileSize
new6.7 KB

i have found theme() function which can help but its not displaying data in to theme format. I have copied my recent code as well as screen shot also.

function modulename_view($node, $teaser = FALSE, $page = FALSE)
{
	global $user;

       db_set_active('another_db');
       $sql = 'SELECT * FROM {another_table} WHERE user_id = '.$user->uid;
	
	$header = array(
				array('data' => 'test', 'field' => 'folder_name'),
				array('data' => 'created_date', 'field' => 'created_date')
			);
	$result = pager_query($sql, 50);
	while ($data = db_fetch_object($result)) 
	{
		$rows[] = array($data->folder_name, $data->created_date);
	}
	if (!$rows) 
	{
		$rows[] = array(array('data' =>t('Empty at the moment..'), 'colspan' => '2'));
	}
	echo theme('table', $header, $rows);
	echo theme('pager', NULL, 50, 0);

	db_set_active('default');
}


If anyone can help me to display this data in proper format than i will be thankfull to you.

Thank you
Tejas Mehta

tejaspmehta’s picture

Status: Active » Closed (fixed)
drgoettel’s picture

Could you post the answer to your question so everybody can learn how to solve it??

Thankyou!

priyanka.salunke’s picture

Title: How to display data from different database in particular page ? » How to display data from database in particular page in tabular format?
priyanka.salunke’s picture

Title: How to display data from database in particular page in tabular format? » How to display data from different database in particular page?