here's the revised loop....
$cat_cnt = count($catalog);
while (list($key,$value) = each($mycart))
{
for ($j = 0; $j < $cat_cnt; $j++)
if ($value == $catalog[$j]["itemcd"])
{
echo $catalog[$j]["unitprice"];
break;
}
}
-----Original Message-----
From: Martin Towell [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 1:50 PM
To: '[EMAIL PROTECTED]'; Tom Rogers; Php
Subject: RE: [PHP] beginner in PHP
Ah! $catalog is a 2D array - any your if statement is expecting a 1D
array...
-----Original Message-----
From: Phillip Perry [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 1:52 PM
To: Tom Rogers; Php
Subject: RE: [PHP] beginner in PHP
I meant Martin :) sorry.
-----Original Message-----
From: Phillip Perry [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 11:44 PM
To: Tom Rogers; Php
Subject: RE: [PHP] beginner in PHP
Array ( [0] => gerainiums [1] => roses [2] => roses [3] => roses [4] =>
roses [5] => roses )
1
1
Your output is different from the last print_r that Tom had me do. I wonder
why that is
-----Original Message-----
From: Tom Rogers [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 11:44 PM
To: [EMAIL PROTECTED]; Php
Subject: RE: [PHP] beginner in PHP
Hi
Then I guess you will have to add some debug code
try this before the while loop and make sure your if ($value ==
$catalog["itemcd"]) will produce a match (and you do need the quotes really
:)
echo "<pre>".print_r($catalogue)."<br>".print_r($mycart)."</pre>";
Tom
At 11:31 PM 12/06/2002 -0400, Phillip Perry wrote:
>Thanks, but that didn't work either
>
>-----Original Message-----
>From: Tom Rogers [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, June 12, 2002 11:32 PM
>To: [EMAIL PROTECTED]; Php
>Subject: Re: [PHP] beginner in PHP
>
>
>Hi
>itemcd and unitprice should be in quotes I think if they are keys in an
>array.
>$catalog["itemcd"]
>$catalog["unitprice"]
>
>Tom
>
>At 10:56 PM 12/06/2002 -0400, Phillip Perry wrote:
> >Can someone tell me why this doesn't work?
> >The $mycart array is fine and the $catalog array is also fine but nothing
> >inside the if statement prints. I've tried other echo statements but
>nothing
> >prints at all.
> >
> >while (list($key,$value) = each($mycart))
> > {
> > if ($value == $catalog[itemcd])
> > {
> >
> > echo $catalog[unitprice];
> >
> > }
> > }
> >
> >
> >Thanks
> >
> >Phil
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php