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]<br>";
                mssql_close ($conn1);
                }
mssql_close ($conn);

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

$result=mssql_query("procedure_in_db1 $productname", $db1); //in $db1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.