so, I'm officially at a standstill and I need some help with a query i'm trying to perform.
a little background :
currently, my script parses a log file, and dumps it into a mysql database so that i can query it easier, and always have that data there (instead of having to parse the log file each and every time i want to run a report ).
So, right now i'm just trying to sort my packets based on when they were sent. I'm wanting to add up all the packets sent between each hour of the day ( ie, between 12:00am - 01:00am total packets =$a, 01:00am - 02:00am total packets = $b, etc ).
I currently have written a rather extensive loop that I have been biting nails with to get to work, but no matter how i arrange the loop, all i get back is a blank page... I was hoping someone could shed some light on where i'm going wrong. I'd really appreciate it..
without further adue, here is what i'm doing :
Code: Select all
<?php
@mysql_pconnect ('localhost','username','password');
@mysql_select_db ('logparser');
$this = "Select * from log";
$some = mysql_query($this);
$numrows = mysql_num_rows($some);
$ctime = array('00:00:00','01:00:00','02:00:00','03:00:00','04:00:00','05:00:00','06:00:00','07:00:00','08:00:00','09:00:00','10:00:00',
'11:00:00','12:00:00','13:00:00','14:00:00','15:00:00','16:00:00','17:00:00','18:00:00','19:00:00',
'20:00:00','21:00:00','22:00:00','23:00:00','24:00:00');
$i=0;
$ii=count($numrows);
$b=1;
$bb=count($numrows);
for ($i=0; $i < $ii; $i++)
{
foreach($ctime as $time)
{
for ($b=1; $b<$bb; $b++)
{
// $i will stand for the first array value of $ctime and $b will stand for the second.
$bob = "SELECT packets FROM log WHERE time > '".$time[$i]."' and time < '".$time[$b]."'";
$result = mysql_query($bob);
echo $result;
echo '<br />';
}
}
}
?>i've tried taking out the incrimenting variables and sticking with just the "foreach" statement, tried it with just the inc variables and no foreach (replacing $time with $ctime of course ), and on and on.
all i want to do is grab data from a table that may look like this :
Code: Select all
time | Packets Sent
-------------|-------------------
00:40:44 | 28348
00:50:34 | 39493
00:55:00 | 34834
02:41:24 | 8384
05:10:44 | 101000
00:15:44 | 40040between 12:00am and 1:00am
sent 102675 packets
between 1:00am and 2:00am
Sent - 0 packets
and so on .
can anyone help this tired young man that's about to lose his mind ?