i try to solve a problem but did not succeed.
I have a index page and users search. for example

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

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

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