Adding 2 mysql queries that has same no of fields but from diff tables
<p>Below is my code to add the two different query results into one. This is working fine when both the queries have same no.of rows.</p>

<p>eg:</p>

<pre><code>row1 = 1 2 3 (Query1)

row2 = 3 5 5 (Query2)

o/p:    4 7 8
</code></pre>

<p>Let's say, I have few rows which are not exactly matched with first query.</p>

<p>eg:</p>

<pre><code>row1 =  1      2       3      2   (Query1)

row2 =  3    empty empty      5   (Query2)

o/p :   4      2       3      7   (I want the o/p to be like this)
</code></pre>

<p>empty means there is no data from the second query.</p>

<p>In my while, &amp;&amp; working fine when the 2 queries have same no.of rows.</p>

<pre><code>while (($row1 = mysql_fetch_assoc($rs1)) &amp;&amp; ($row2 = mysql_fetch_assoc($rs2)))
{


$strHtml .= "&lt;tr&gt;";

$strHtml .= "&lt;td align=center colspan=3&gt;".($row1['Calls']+$row2['Calls'])."&lt;/td&gt;";
$strHtml .= "&lt;td align=center colspan=3&gt;".($row1['actual_duration(min)A']+$row2['actual_duration(min)A'])."&lt;/td&gt;";
$strHtml .= "&lt;td align=center colspan=3&gt;".($row1['call_usage']+$row2['call_usage'])."&lt;/td&gt;";
$strHtml .= "&lt;td align=center colspan=3&gt;".($row1['disconnection_charge']+$row2['disconnection_charge'])."&lt;/td&gt;";
$strHtml .= "&lt;td align=center colspan=3&gt;".($row1['total_revenue']+$row2['total_revenue'])."&lt;/td&gt;";

$strHtml .= "&lt;/tr&gt;";

}
</code></pre>

<p>Is the while loop i am using correct or there is any other better solution for this?</p>

<p>please help me, Thanks in advance.</p>
