Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7531019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:04:19+00:00 2026-05-30T05:04:19+00:00

i try to solve a problem but did not succeed. I have a index

  • 0

i try to solve a problem but did not succeed.

I have a index page and users search. for example

enter image description here

What i want to do is to have subtotal. I mean i want to have a total according to day.

for example user search for 2012-02-22 and 2012-02-23 but i need total for 22 and 23 of month .

To do that: I did this it calculate on t

while ($info = mysql_fetch_array($dbResult)) {
                                                    $total+= $info['totalEvents'];
                                                    $total2 = 0;
                                                    echo "<tr>";
                                                    echo "<td><input type=checkbox name='check1' id='check1' value='" . $info['eventCategory'] . "' onclick=recal(" . $info['totalEvents'] . ",this.checked) checked></td>
                                                     <label id ='nameID'><td>" . $info['id'] . "      " . $info['profileName'] . "</td>";
                                                    echo "<td><label id='eventCategory'>" . $info['eventCategory'] . "</td>";
                                                    echo "<td><label id='totalEvents'>" . $info['totalEvents'] . "</label></td>";

                                                    if ($info['Date'] != $previousDate) {
                                                        echo "<td><b>" . $info['Date'] . "</b></td></tr>";
                                                        $total2++;
                                                    } else {
                                                        echo "<td></td>";
                                                    }
                                                    $previousDate = $info['Date'];
                                                }

but it calculates like that

enter image description here

finally i come to this
but i calculates wrongly

else if ($_POST['group1'] == 'VideoFinish') {
                                                $dbResult = mysql_query("SELECT la.id,st.profileName, la.totalEvents,la.Date,ft.eventCategory FROM videofinish la INNER JOIN profiles st ON st.id=la.id INNER JOIN eventcategory ft ON ft.id = la.eventCategoryID where Date BETWEEN '" . $startDate . "' and '" . $endDate . "'");

                                                if (isset($_POST['checkPremium'])) {
                                                    $dbResult = mysql_query("SELECT la.id,st.profileName, la.totalEvents,la.Date,ft.eventCategory FROM videofinish la INNER JOIN profiles st ON st.id=la.id and st.isPremium=1 INNER JOIN eventcategory ft ON ft.id = la.eventCategoryID where Date BETWEEN '" . $startDate . "' and '" . $endDate . "'");
                                                }

                                                $previousDate = '';
                                                $totalDay = 0;
                                                while ($info = mysql_fetch_array($dbResult)) {
                                                    $total+= $info['totalEvents'];
                                                    echo "<tr>";
                                                    echo "<td><input type=checkbox name='check1' id='check1' value='" . $info['eventCategory'] . "' onclick=recal(" . $info['totalEvents'] . ",this.checked) checked></td>
                                                     <label id ='nameID'><td>" . $info['id'] . "      " . $info['profileName'] . "</td>";
                                                    echo "<td><label id='eventCategory'>" . $info['eventCategory'] . "</td>";
                                                    echo "<td><label id='totalEvents'>" . $info['totalEvents'] . "</label></td>";

                                                    if ($info['Date'] != $previousDate && $info['Date'] != $previousDate) {
                                                        echo "<td><b>" . $info['Date'] . "</b></td></tr>";
                                                        echo "<b>".$info['Date']."</b>:";
                                                         echo  $totalDay."<br />";
                                                    } else {

                                                        echo "<td></td>";
                                                    }
                                                    $previousDate = $info['Date'];
                                                    $totalDay += $info['totalEvents'];


                                                }
                                                echo "<td><b id='total'>" . $total . "</b></td>";

                                            }

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:04:20+00:00Added an answer on May 30, 2026 at 5:04 am

    Try this .. i put comments in the code for your understanding.

    // initialize counter and previous date
    $totalDay = 0;
    $previousDate = NULL;
    
    // we need to change the loop structure so that the loop code is executed
    // a last time when there are no further rows. Otherwise, we would have
    // no total on the last day!
    while (true) {
        // we break the loop when there are no further rows after sub total is printed
        $info = mysql_fetch_array($dbResult);
    
        // when date changes, print total line and reset counter
        if ( $previousDate <> NULL && 
            ( !isset($info['Date']) || $info['Date'] <> $previousDate ) ) {
            echo '<tr>';
            // no checkbox
            echo '<td></td>'; 
            // label in second cell
            echo '<td><b>Total for day ' . $previousDate .'</b></td>';
            // total in last cell
            echo '<td colspan="4" align="right"><b>' . $totalDay . '</b></td>';
            echo '</tr>';
            // day has changed, so reset the sub total for next day
            $totalDay = 0;
        }
    
        // now if the have no further rows, break the loop
        if ($info == false)
            break;
    
        // add current value to sub total
        $totalDay += $info['totalEvents'];
    
        echo "<tr>";
        echo "<td><input type=checkbox name='check1' id='check1' value='" . $info['eventCategory'] . "' 
                onclick=recal(" . $info['totalEvents'] . ",this.checked) checked></td>";
        echo "<label id ='nameID'><td>" . $info['id'] . "      " . $info['profileName'] . "</td>";
        echo "<td><label id='eventCategory'>" . $info['eventCategory'] . "</td>";
        echo "<td><label id='totalEvents'>" . $info['totalEvents'] . "</label></td>";
    
        echo "<td>";    
        // when date changes (also on first day), print date
        if ($info['Date'] <> $previousDate) {
            echo "<b>" . $info['Date'] . "</b>";
        }
        echo "</td>";
        echo "</tr>";
    
        // remember current date for next row calculation
        $previousDate = $info['Date'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem that I could not solve. When I try to
I have a problem, which I do not seem to be able to solve...
I try to solve this problem several times and give up. Now, when I
I'm sorry if this has been asked before, but I did try digging through
There are many questions about this PersistenceException, but I have not seen some, where
Try to see which cast is faster (not necessary better): new c++ case or
I have a centralized Mercurial repository which I want to provide access to via
According to numerous sources, for example Limitations section on official page , probably the
I have a strange problem. I am getting a stream of text from a
Solved the problem see the bottom of my post. So I have a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.