That will zero fill any elements that don't have data, but it won't move the
data in the elements to the right positions. Each element is supposed to
represent a day of the week, starting at Sunday. So if I have data
representing calls that came in on Tuesday and Thursday, I need that data in
elements 2 and 4. The way it comes from my query, the data is at elements 0
and 1. So yes, I do need to add the zero's to the other 5 days, which your
code does (much neater than any of my attempts as well), but it doesn't
"arrange" the data the way I need.

Thanks for taking a shot at it though, I appreciate it!

-----Original Message-----
From: Szii [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 6:27 PM
To: Tyrone Mills; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Can't get my head around this problem...


Perhaps...?

$x = 0;
while ($x < 7)
{
  if (!isset($myArray[$x]))
  {
     $myArray[$x] =0;
  }
}

-Szii

----- Original Message -----
From: "Tyrone Mills" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 24, 2001 3:58 PM
Subject: [PHP-DB] Can't get my head around this problem...


> Hello all...
>
> I've got what is probably a stupid question, it's a problem I can't seem
to
> get my head around it. Any help will be greatly appreciated.
>
> I'm pulling a count of connections from a MySQL database and the day of
the
> week it occurred on. Now the result set doesn't include empty values, so
if
> there were connections on only 2 days, I only get 2 rows returned, if
there
> were connections on 4 days, I get 4 rows returned. You get the idea...
>
> Here is the PHP code I am using the get the data:
>
> $sql = "SELECT COUNT(*), (DAYOFWEEK(dialer_login_date) -1) AS DAYOFWEEK
FROM
> dialer_login WHERE dialer_id = $dialer_id AND
> WEEK(date_format(dialer_login_date, '%Y-%m-%d'),0) = WEEK('$last_week',0)
> GROUP BY DAYOFWEEK";
>
> $result = db_query($sql);
>
> while ($daily_count = db_fetch_array($result))
> {
>
> $lastweek[] = $daily_count["COUNT(*)"];
> $day[] = $daily_count["DAYOFWEEK"];
>
> }
>
> For the sake of this question, let's say that there were connections on
only
> 2 days, so we get a result set with 2 rows. Something like this:
>
> COUNT(*) DAYOFWEEK
> 8 2
> 3 4
>
> That's great, but I need the array $lastweek to have the value 8 in
element
> 2 and the value 3 in element 4 and all other elements (0,1,3,5,6) as zero.
> As it sits, they are in elements 0 and 1 respectively.
>
> I get this:
>
> $lastweek[] = 8,3
>
> I need this:
>
> $lastweek[] = 0,0,8,0,3,0,0
>
> Now I've written all manner of wild and wonderful loops that iterate
through
> either $lastweek or $day and try and build a proper array. Invariably
> something doesn't work right. I'm sure I'm grossly over complicating this,
> but I am at my wits end. Any thoughts or ideas are most welcome.
>
> Thanks!!
>
> Tyrone Mills
> ____________________________________________________
> UNIX is user-friendly, it's just picky about who its friends are...
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to