how to retrieve data from two tables

Reply

Join Date: Jun 2005
Posts: 92
Reputation: michael123 is an unknown quantity at this point 
Solved Threads: 0
michael123 michael123 is offline Offline
Junior Poster in Training

how to retrieve data from two tables

 
0
  #1
Jul 13th, 2009
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);
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 3
Reputation: Thyrosis is an unknown quantity at this point 
Solved Threads: 0
Thyrosis Thyrosis is offline Offline
Newbie Poster

Re: how to retrieve data from two tables

 
0
  #2
Jul 14th, 2009
You'd be looking at using the mssql_query's second variable: the connection.

  1. $result=mssql_query("procedure_in_db1 $productname", $db1); //in $db1
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC