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>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.