select hour(ts), count(ts) from dundeefw 
where date=$date and action=1 
group by hour(ts)

Assuming "ts" is your timestamp column ...

Tom Haapanen
[EMAIL PROTECTED]

-----Original Message-----
From: Leon Noble [mailto:[EMAIL PROTECTED]]
Sent: 23 October 2001 05:45 
To: [EMAIL PROTECTED]
Subject: Very untidy


Hi all,

can someone look at my very untidy code and maybe give me some pointers.

Searching for values by the hour.

etc

for ($i = 0; $i <= 23; $i++)
{
    $query = "select count(num) as mycount from dundeefw where date=$date
and action=1 and time=hour($i)";

    // Execute query
    $result = mysql_query($query) or die ("Query Failed");

    while ($row = mysql_fetch_array ($result))
    {
        $connection[$i] = $row["mycount"];
    }
}

I am wondering if there is anyway using SQL to avoid doing this the very
messy way.

many thanks

Leon.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to