Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2010, 05:18 AM   PM User | #1
newphpcoder
Regular Coder

 
Join Date: Aug 2010
Posts: 653
Thanks: 155
Thanked 0 Times in 0 Posts
newphpcoder is an unknown quantity at this point
Problem viewing shift reports

Good day!

I have 2 kinds of shift and it is also the same they are only different in Forms. I copy the code for shift and i edit it, but i only edit the names of database,fields and tables, so I don't why the shift for 10-6 was not view or appear. Here is the code:

PHP Code:
If($_POST["clt_shift_date"])
        {
        
            
        
$clt_shift[] = '10-6';
        
$clt_shift[] = '6-2';
        
$clt_shift[] = '2-10';
        
        
$firstclt_shift_date $_POST["clt_shift_date"];
        
$firstclt_shift_date date("Y-m-d"strtotime('-1 day',strtotime($firstclt_shift_date)));
        
        
$query "SELECT d.operation_name, SUM(d.input_qty) AS inputqty, d.input_unit, SUM(d.output_qty) AS outputqty, d.output_unit, d.shift FROM clt_traceability d, clt_transact t WHERE ((t.clt_date = '$firstclt_shift_date' AND d.shift = '10-6') || (t.clt_date = '" $_POST["clt_shift_date"] . "' AND d.shift = '6-2') || (t.clt_date = '" $_POST["clt_shift_date"] . "' AND d.shift = '2-10')) AND d.clt_transact_id = t.clt_transact_id GROUP BY d.operation_name, d.output_unit, d.input_unit, d.shift ORDER BY d.operation_name, FIELD(d.shift,'10-6','6-2','2-10')";
        
$result mysql_query($query);
        
        if(
$result)
            {
            echo 
"<table cellspacing='3' style='font-family: arial narrow; font-size: 12px; border-width: 2px 2px 2px 2px; border-style: solid;'>";
            echo 
"<tr><b> Date: &nbsp;  " $_POST['clt_shift_date'] . "</b></tr>";
        
            echo 
"<tr>";
            echo 
"<th class='tdclass'>Operation</th>";
            
$shift_ctr count($clt_shift);
            for(
$ctr 0$ctr $shift_ctr$ctr++)
                echo 
"<th colspan='2' class='tdclass'>" $clt_shift[$ctr] . "</th>";
                
            echo 
"</tr>";
            
            echo 
"<tr>";
            echo 
"<td class='tdclass'></td>";
            
$shift_ctr count($clt_shift);
            for(
$ctr 0$ctr $shift_ctr$ctr++)
                echo 
"<td class='tdclass'>Input</td><td class='tdclass'>Output</td>";
                
            echo 
"</tr>";
            
            
$last_opname "";
            
$tdctr 0;
            while(
$row2 mysql_fetch_array($result))
                {
                
$opname $row2["operation_name"];
                
$i strpos($opname," ",0);
                
$opname substr($opname,$i);
                if(
$last_opname != $opname && $last_opname != "")
                    {
                     if(
$tdctr $shift_ctr)
                        {
                        for(
$tdctr=$tdctr$tdctr $shift_ctr$tdctr++)
                            {
                            echo 
"<td class='tdclass'>&nbsp;</td>";
                            echo 
"<td class='tdclass'>&nbsp;</td>";
                            }
                        }
                    echo 
"</tr>";
                    echo 
"<tr>";
                    echo 
"<td class='tdclass'>" $opname "</td>";
                    
$tdctr 0;
                    }
                elseif(
$last_opname != $opname)
                    {
                    echo 
"<tr>";
                    echo 
"<td class='tdclass'>" $opname "</td>";
                    }
                
                
$last_opname $opname;
                
                for(
$ctr=0$ctr $shift_ctr$ctr++)
                    {
                        
                    if(
$row2["shift"] == $clt_shift[$ctr])
                        {
                        echo 
"<td class='tdclass'>" number_format($row2["inputqty"],2) . "</td>";
                        echo 
"<td class='tdclass'>" number_format($row2["outputqty"],2) . "</td>";
                        
$tdctr++;
                        
$ctr $shift_ctr+1;
                        }
                    elseif(
$ctr == $tdctr)
                        {
                        echo 
"<td class='tdclass'>&nbsp;</td>";
                        echo 
"<td class='tdclass'>&nbsp;</td>";
                        
$tdctr++;
                        }
                    }
                }
            echo 
"</table>";
            }
            
        } 
Only the 6-2 and 2-10 data was appear.

Thank you
newphpcoder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:45 PM.


Advertisement
Log in to turn off these ads.