Combining Recordsets in Dreamweaver

How do I combine two recordsets into one in Dreamweaver?  (MX2004) I am using PHP and MYSQL.
Explanation: This is an events page.  I have two recordsets, each one is pulling information from two identical tables located in separate databases (different connections), combining the data to produce one output of a complete list.
I have read up on the JOIN and UNION statements, just not sure exactly how to implement or what the syntax would be to implement this.  I am assuming I need a third recordset to combine the two.
Can anyone enlighten me?  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There's no way to combine the results using DW behaviours or php's mysql functions.

The solution is to use php to loop out the results of both queries into the same array, then use the php array to output the records.

An example in psudocode is below:
//your DW recordsets here
//combine results into array
$arr_results = array();
//loop out first result into array
if($rsResult1_row) {
	$i = 0;
		$arr_results[$i]['dbColumn1'] = $rsResult1_row['dbColumn1'];
		$arr_results[$i]['dbColumn2'] = $rsResult1_row['dbColumn2'];
		$arr_results[$i]['dbColumn3'] = $rsResult1_row['dbColumn3'];
		$arr_results[$i]['dbColumn4'] = $rsResult1_row['dbColumn4'];
	  } while ($rsResult1_row = mysql_fetch_assoc($rsResult1_qry));
//loop out second result into array
if($rsResult2_row) {
		$arr_results[$i]['dbColumn1'] = $rsResult2_row['dbColumn1'];
		$arr_results[$i]['dbColumn2'] = $rsResult2_row['dbColumn2'];
		$arr_results[$i]['dbColumn3'] = $rsResult2_row['dbColumn3'];
		$arr_results[$i]['dbColumn4'] = $rsResult2_row['dbColumn4'];
	  } while ($rsResult2_row = mysql_fetch_assoc($rsResult2_qry));
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Combining Recordsets</title>
<table width="400" border="0" cellspacing="1" cellpadding="3">
    <th scope="col">dbColumn1</th>
    <th scope="col">dbColumn2</th>
    <th scope="col">dbColumn3</th>
    <th scope="col">dbColumn4</th>
	//loop out the array if results
	if(!empty($arr_results)) {
		foreach($arr_results as $k => $v {
    <td><?php echo $v['dbColumn1']; ?></td>
    <td><?php echo $v['dbColumn2']; ?></td>
    <td><?php echo $v['dbColumn3']; ?></td>
    <td><?php echo $v['dbColumn4']; ?></td>
		//end loop
	//end if
	} else {
	//display no results
    <td colspan="4">
      <div align="center">no results to display</div>
	//end display no results

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I can see a parse error on line 60. Change it to:

                foreach($arr_results as $k => $v) {
OwenSmartAuthor Commented:
tx, i will give this a try.

Is there any way to use UNION or JOIN to create the same result - keeping in mind that i have to connect to two different databases to retrieve the data, which is stored in identically structured tables.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

As previously mentioned, no. You cannot interact with 2 mysql servers in the one query.
Jason C. LevineNo oneCommented:
>> You cannot interact with 2 mysql servers in the one query.

Correct.  One wonders why the data is spread out over two servers if the intent is to use it in this manner?
So is this NOT then considered a recordset?  This is the exact kind of thing I need, but I need it to be in a recordset.  This is because the page uses a Trigger that calls a recordset and emails that way.
No - it isn't. Use the solution posted to join the two recordsets in a php array.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.