I want to try multiple while in one while with multiple tables but it's doesn't work.
I have three table and I want a different-different value from table.
Here is my code.
$table1 = GROUPMASTER;
$table2 = LEDGERMASTER;
$table3 = TRANSECTIONMASTER;
$groupmasterdata = mysql_query("select * from $table1 WHERE groupname = 'Capital' OR groupname = 'Fund and Reserves' OR groupname = 'Long Term liabilities' OR groupname = 'Current Liabilities' ");
echo "<table align='center' border=1>";
echo "<tr>";
echo "<td colspan=2 style='text-align:center'><b> CAPITAL and LIABILITIES</b></td>";
echo "<td style='text-align:center'><b> Amount </b></td>";
echo "</tr>";
while($recored = mysql_fetch_array($groupmasterdata))
{
$onegroupname = $recored ['groupname'];
echo "<tr>";
echo "<td colspan=3><b>" . strtoupper($onegroupname) . "</b></td></tr>";
$groupnamelist = mysql_query("select groupname from $table1 WHERE under = '". $onegroupname ."'");
while($data = mysql_fetch_array($groupnamelist))
{
$gname = $data ['groupname'];
$getledgername = mysql_query("select ledgername from WHERE groupname = '". $gname ."'");
while($lname = mysql_fetch_array($getledgername))
{
$gettocashbal = mysql_query("select *, SUM(amount) AS totalto from $table3 WHERE voucherto = '". $ledgername ."'");
while($datato = mysql_fetch_array($gettocashbal))
{
$tototal = $datato['totalto'];
}
$getbycashbal = mysql_query("select *, SUM(amount) AS totalby from $table3 WHERE voucherby = '". $ledgername ."' ");
while($databy = mysql_fetch_array($getbycashbal))
{
$bytotal = $databy['totalby'];
}
$ledgertotal = $opbal - $tototal + $bytotal;
echo "<tr>";
echo "<td class='test'>" . $gname . "</td>";
echo "<td>Rs. $ledgertotal</td>";
echo "<td></td>";
echo "</tr>";
}
}
echo "<tr>";
echo "<td style='text-align:right'>Total</td>";
echo "<td></td>";
echo "<td>Rs.</td>";
echo "</tr>";
}
echo "</table>";
I want to try multiple while but doesn't work.
How can I solve these issues?