I am using the query below to count the amount of records with distinct values in the "Period" column. The Period column contains either "Breakfast", "Lunch" or "Dinner", and the output of the formula is grouped by monthly columns and then one row for each distinct value:
Ttl. Feedback : Breakfast: XXX
Ttl. Feedback : Lunch: XXX
Ttl. Feedback : Dinner: XXX
Now, what I would need is a variable for each total number (see $mydata['total'] that is returned for Breakfast, Lunch and Dinner. The current variable only returns the total for each distinct value, and doesnt let me specifically address an individual period score.
<?
$whereParts = array();
if ($property) {
$whereParts[] = "Holidex = '$property' ";
}
$whereParts = array();
if ($outlet) {
$whereParts[] = "Outlet = '$outlet' ";
}
if ($pickyear) {
$whereParts[] = "YEAR(Date) = '$pickyear' ";
}
$sql = ("select distinct period from FB_Feedback_Card_Data");
//BUILD THE FINAL QUERY
if (count($whereParts) > 0) {
$sql .= " WHERE " . implode('AND ', $whereParts);
}
//count($whereParts) > 0
$result = $mysqli->query($sql) or die('<p>Query to get case Period data from FB_Feedback_Card_Data table failed:' . mysql_error() . '</p>');
while ($row = mysqli_fetch_row($result))
{
$period = $row[0];
//echo "$status <br>";
$mydata = stats("period", "$period", "$property", "$outlet", "$pickyear",$mysqli);
?>
<tr>
<td class="result_desc"><?echo "Ttl. Feedback : $period";?></td>
<td class="result"><? echo $mydata['a']; ?></td>
<td class="result"><? echo $mydata['b']; ?></td>
<td class="result"><? echo $mydata['c']; ?></td>
<td class="result"><? echo $mydata['d']; ?></td>
<td class="result"><? echo $mydata['e']; ?></td>
<td class="result"><? echo $mydata['f']; ?></td>
<td class="result"><? echo $mydata['g']; ?></td>
<td class="result"><? echo $mydata['h']; ?></td>
<td class="result"><? echo $mydata['i']; ?></td>
<td class="result"><? echo $mydata['j']; ?></td>
<td class="result"><? echo $mydata['k']; ?></td>
<td class="result"><? echo $mydata['l']; ?></td>
<td class="result_ytd"><strong><? echo $mydata['total']; ?></strong></td>
</tr>
<?
// end total status stats
}
?>