Re: Array Push and Keys
| From: | Mike Morton | Date: | Fri, 29 Aug 2003 15:47:06 +0000 |
| Subject: | Re: Array Push and Keys | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-161146@lists.php.net to get a copy of this message | ||
The code that I ended up using was:
$res=mysql_query("select distinct dealercode from transactions where
dealercode!='' order by dealercode",$intranet);
$count=0;
while($row=mysql_fetch_array($res)) {
$amt=mysql_query("select sum(amount) as total from transactions where
date between '2003-04-01' and '2003-06-31' and
dealercode='$row[dealercode]'",$intranet);
$afftotal=mysql_fetch_array($amt);
$transactions[$row[dealercode]]["onlineu"]=$afftotal[total];
$amt=mysql_query("select usercountry,sum(amount) as total from
orders_placed where date between '2003-04-01' and '2003-06-31' and
dealercode='$row[dealercode]' and sent='y' group by
usercountry",$intranet);
while($cdtotal=mysql_fetch_array($amt)) {
$transactions[$row[dealercode]][$cdtotal[usercountry]]=$cdtotal[total];
}
}
On 8/29/03 11:38 AM, "John W. Holmes" <holmes072000@charter.net> wrote:
> Ford, Mike [LSS] wrote:
>
>> Having said that, I've just given you a clue: since array_push($array, $var)
>> is equivalent to $array[] = $var, you can get the result you want by doing:
>>
>> $array[] = array($k, $v);
>>
>> (with, of course, appropriate values for $array, $k and $v substituted to
>> suit your code!).
>
> Shouldn't that be:
>
> $array[$k] = $v;
--
Cheers
Mike Morton
****************************************************
*
* Tel: 905-465-1263
* Email: mike@webtraxx.com
*
****************************************************
"Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple."
- Byte Magazine
Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey