What I need is to take an issue id and track user submitted upvotes by the hour. I'm running into a wall when I try to get the data out of the array coherently for PHPExcel charting purposes.
I end up with this $hourlyUpvotesTodayResult[] array, which has the correct number of votes for each hour (verified through print_r), but I want to group them in such a way where I can do something like "for each issue id display the hours 0-24 and the total votes for each hour". Maybe I'm overthinking it and missing something simple.
Also, please ignore the ancient MySQL - I'm working on some existing code, I know it's deprecated and I'll get around to updating it someday :D
while ($todayInfoRow = mysql_fetch_array($todayInfoQuery))
{
$issue_entry_id_today = array($todayInfoRow['issue_entry_id']);
foreach ($issue_entry_id_today as $issue_entry_id_today)
{
$todayInfoUpvotes = "SELECT id from $db.$tb2 WHERE date = '".$date."' and issue_entry_id = '".$issue_entry_id_today."' ORDER BY issue_entry_id DESC";
$todayInfoUpvotesQuery = mysql_query($todayInfoUpvotes)or die(mysql_error());
$todayInfoUpvotesRow = mysql_num_rows($todayInfoUpvotesQuery);
$todayInfoResult = array($issue_entry_id_today, $todayInfoUpvotesRow);
}
// get votes for individual hours for today
for ($hour_today=0; $hour_today<25; $hour_today++)
{
$hourlyUpvotesToday = "SELECT id from $db.$tb2 WHERE date = '".mysql_real_escape_string($date)."' AND issue_entry_id = '".$issue_entry_id_today."' AND hour = '".$hour_today."' ORDER BY issue_entry_id DESC";
$hourlyUpvotesTodayQuery = mysql_query($hourlyUpvotesToday)or die(mysql_error());
$hourlyUpvotesTodayRow = mysql_num_rows($hourlyUpvotesTodayQuery);
$hourlyUpvotesTodayResult[] = array('id'=>$issue_entry_id_today, 'upvotes'=>$hourlyUpvotesTodayRow, 'hour'=>$hour);
}
}
//debug print array
print_r($hourlyUpvotesTodayResult);