Jump to content

Recommended Posts

In this report I want to create a line break and a Total line for each State.

 

 while ($row = odbc_fetch_array($result))
{
    echo "<tr><td>" .  $row['cmlstate']."</td>";
    echo "<td>" .  $row['cmlpostcode']."</td>";
    echo "<td>" .  $row['cmlcity']."</td>";
    echo "<td>" .  $row['ompSalesOrderID']."</td>";
    echo "<td>" .  $row['cmoName']."</td>";
    echo "<td>" .  number_format($row['UOMPVOLUMETOTAL'],2)."</td>";
    echo "<td>" .  number_format($row['UOMPTOTALBOXCOUNT'],0)."</td>";
    echo "<td>" .  $row['Hold']."</td></tr>"; 
    

I want to sum 'UOMPVOLUMETOTAL' for each state and create a line break between it and the next state.
    
}

 

Link to comment
https://forums.phpfreaks.com/topic/311344-create-a-total-line-for-each-state/
Share on other sites

That's not very good table design, but whatever.

You're running a second query to get totals, right? Have the query return a count of rows too. (So AL has 10 rows, AR has 5, and so on.)

Before your loop, start a counter at 0. Increment the counter every time you print a row. When that counter reaches the number of rows the state has, print out a separate <tr> row with the information you want. Then reset the counter to 0 for the next state's rows.

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.