954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to retrieve data from two tables

I need to manipulate two tables(in different DB) to print out data, what's the effective way to do that in php code?
$conn = mssql_connect($intraserver, $intrauser, $intrapass);
$db=mssql_select_db($intradb, $conn);

$result0=mssql_query("select a from tb1");// in $db
for ($i = 0; $i < @mssql_num_rows( $result0 ); ++$i)
{
$line = @mssql_fetch_row($result0);
$productname=$line[0];

$conn1 = mssql_connect($intraserver1, $intrauser1, $intrapass1);
$db1=mssql_select_db($intradb1, $conn1);

$result=mssql_query("procedure_in_db1 $productname"); //in $db1
$arr = mssql_fetch_row($result);
print "$arr[0]";
mssql_close ($conn1);
}
mssql_close ($conn);

michael123
Junior Poster in Training
94 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

You'd be looking at using the mssql_query's second variable: the connection.

$result=mssql_query("procedure_in_db1 $productname", $db1); //in $db1
Thyrosis
Newbie Poster
3 posts since Jul 2009
Reputation Points: 13
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You