943,660 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 671
  • PHP RSS
Jul 13th, 2009
0

how to retrieve data from two tables

Expand Post »
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);
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
michael123 is offline Offline
93 posts
since Jun 2005
Jul 14th, 2009
0

Re: how to retrieve data from two tables

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

PHP Syntax (Toggle Plain Text)
  1. $result=mssql_query("procedure_in_db1 $productname", $db1); //in $db1
Reputation Points: 13
Solved Threads: 0
Newbie Poster
Thyrosis is offline Offline
3 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Forum: how much time did it take you to create one?
Next Thread in PHP Forum Timeline: Php, ajax, mysql live search help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC