Sir I have these 2 tables (Arrival+Pouring) shown in Attachment

I create result table with this query

select c1.date,sum(nvl(cx.purchase-cx.sold,0))  as opening,c1.purchase,c1.sold,;
        sum(nvl(cx.purchase-cx.sold,0)) + c1.purchase-c1.sold as closing ;
    from ;
        (select NVL(a.date,b.date) as date,CAST(NVL(a.qty,0) as integer) as purchase,;
        CAST(NVL(b.qty,0) as integer) as sold from purchase a FULL JOIN sold b ON a.date = b.date order by 1) c1 ;
    left join;
     (select NVL(a.date,b.date) as date,CAST(NVL(a.qty,0) as integer) as purchase,;
     CAST(NVL(b.qty,0) as integer) as sold from purchase a FULL JOIN sold b ON a.date = b.date order by 1) cx ;
    on c1.date>cx.date;
     group by c1.date,c1.purchase,c1.sold

The query work fine to get opening and closing balance.
But I want to use PHP Codes like array and echo etc to show result.

Please help me to convert the query into php codes.

Thanks

Recommended Answers

All 3 Replies

You may also have to reveal if the output in your picture was the result of some Word document, HTML, LaTex or other system.
Complete your "specification" since PHP output can be text or other depending on your php foo.

Sir, I prepared an Excel Sheet for result. I enter accuarate result to show you what out put i need.

acutally I need this type of codes

$close=0;
$loop=0;

while($row=mysqli_fetch_assoc($res))
{
echo "<table><tr><td>Date</td><td>Opening</td><td>Purchase</td><td>Sold</td><td>Closing</td></tr>";
echo $stock[$loop]["date"]=$row["date"];
$stock[$loop]["close"]=$row["arrqty"]-$row["pourqty"];
$stock[$loop]["arrqty"]=$row["arrqty"];
$stock[$loop]["pouqty"]=$row["pourqty"];
$stock[$loop]["open"]=$close;
$close=$row["arrqty"]-$row["pourqty"];
$loop++;
}
echo "</table>"

I think you want a HTML result so next time be sure to reveal that in your post or spec. You used Excel so that's fine but PHP to Excel files is a whole ball game.

What's up with your current PHP code? Since I can't put it into some PHP fiddle I can't check it for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.