Jump to content

PROBLEM WITH MONTH - DAYS REPEATING AS LONG AS WHILE LOOP EXTRACTS DATA


diginamics

Recommended Posts

Please check the img link and you will understand

 

Untitled-1.jpg

 

for ($index = 1; $index <= $numdays; $index++) {

$users="SELECT invoice_date, DAY(invoice_date) as invoiceday, sum(total_amount) as fullamount from invoices 
WHERE MONTH(invoice_date)='".$month."' AND YEAR(invoice_date)='".$year."' GROUP BY invoiceday";
$res=mysql_query($users);
$row=mysql_num_rows($res);



while($fetch=mysql_fetch_array($res)){


echo "<tr id='". ( ( $j %2 == 0 ) ? 'row3' : 'row4' ) . "'>";

$explodedate=explode("-",$fetch['invoice_date']);
$days=$explodedate[2];
$month1=$explodedate[1];
$year1=$explodedate[0];

$dates=date("jS", strtotime($fetch['invoice_date']));


echo "<td style='text-align:left;padding-left:12px'>".$index."</td>";
if($index==$dates){

echo "<td style='text-align:right;padding-right:12px'>".$fetch['fullamount']."</td>";

}else{		

echo "<td style='text-align:right;padding-right:12px'>--</td>";

}

echo "</tr>";
}



}


$total="SELECT SUM(total_amount) as fulltotal from invoices where MONTH(invoice_date)='".$month1."' AND YEAR(invoice_date)='".$year1."';";

$totres=mysql_query($total);
$totfetch=mysql_fetch_assoc($totres);
if($totfetch['fulltotal']==""){
echo "<tr><td>NOTHING FOUND</td></tr>";
}else{
ECHO "<TR>";
echo "<td style='color:#BD0000;padding-left:12px;border:1px solid #ccc;width:20%;height:40px;text-align:left'>TOTAL AMOUNT FOR ".$displaydate."</td>";
echo "<td style='color:#BD0000;border:1px solid #ccc;width:20%;height:40px;text-align:right;padding-right:12px'>".$totfetch['fulltotal']."</TD></TR>";

}
echo "</table>";

If anyone wants to view, you can view a this working at qasqoos.nsegulf.com/daily_sales_temp.php

It will be showing this month. Because there are invoices only for one day, it shows the month days only once. Just go back to previous month and you will understand what I mean

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.