diginamics Posted April 2, 2011 Share Posted April 2, 2011 Please check the img link and you will understand 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/232493-problem-with-month-days-repeating-as-long-as-while-loop-extracts-data/ Share on other sites More sharing options...
diginamics Posted April 2, 2011 Author Share Posted April 2, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/232493-problem-with-month-days-repeating-as-long-as-while-loop-extracts-data/#findComment-1195901 Share on other sites More sharing options...
sunfighter Posted April 2, 2011 Share Posted April 2, 2011 Checked using FF and IE. Both show things OK for the four months. Can not see a problem. Looking at your code and that looks in order also and more importantly it doesn't look like it would cause the errors your showing. Quote Link to comment https://forums.phpfreaks.com/topic/232493-problem-with-month-days-repeating-as-long-as-while-loop-extracts-data/#findComment-1195980 Share on other sites More sharing options...
diginamics Posted April 2, 2011 Author Share Posted April 2, 2011 Yes Just got solution from another user from another website and updated but could not mark the post as solved over here. Quote Link to comment https://forums.phpfreaks.com/topic/232493-problem-with-month-days-repeating-as-long-as-while-loop-extracts-data/#findComment-1195983 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.