RE: Re[2]: [PHP] beginner in PHP
> -Original Message- > From: Stuart Dallas [mailto:[EMAIL PROTECTED]] > Sent: Thursday, June 13, 2002 2:53 PM > To: Phillip Perry > Cc: Tim Ward; Martin Towell; Tom Rogers; Php > Subject: Re[2]: [PHP] beginner in PHP > > > On Thursday, June 13, 2002 at 7:44:39 PM, you wrote: > > > Yes, here is the checkout code I used... > > > function chout(){ > > session_destroy(); > > unset ($mycart); > > unset ($cart_items); > > echo "Thank you for shopping!"; > > } > > > Any suggestions? > > Try this... > > function chout(){ > global $mycart, $cart_items; > session_destroy(); > unset ($mycart); > unset ($cart_items); > echo "Thank you for shopping!"; > } Still won't work. All that the "global" statement does is make the copy of the variable inside the function be a *reference* to the global copy -- it's basically equivalent to $mycart = & $GLOBALS['mycart']; So, when you unset($mycart) within the function, all you're unsetting is the reference -- the actual global variable is completely unaffected. Thus, the only way to unset a global variable is to reference it in the global context. One way to do this might be: function chout(){ session_destroy(); unset ($GLOBALS['mycart']); unset ($GLOBALS['cart_items']); } Alternatively, just do it in the global context, outside any function. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] beginner in PHP
So how do I affect the local copies of the variables. The global() doesn't seem to work. Should I take everything out of the function and just use if statements? -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: Friday, June 14, 2002 3:46 AM To: [EMAIL PROTECTED]; Tim Ward; Martin Towell; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP You're insetting the variables within the chout() function only This has no effect on the local copies as they are not in scope here. You have successfully destroyed the session so when you refresh they are unset. What I do with sessions is keep them all within a session array so you can then destroy the session locally by unsetting that array. If I have a function that I want to change session variables at all I make it take the session in as a parameter and pass it back as the return value. Tim Ward > -Original Message- > From: Phillip Perry [SMTP:[EMAIL PROTECTED]] > Sent: 13 June 2002 19:45 > To: Tim Ward; Martin Towell; Tom Rogers; Php > Subject: RE: [PHP] beginner in PHP > > Yes, here is the checkout code I used... > > function chout(){ > session_destroy(); > unset ($mycart); > unset ($cart_items); > echo "Thank you for shopping!"; > } > > Any suggestions? > > -Original Message- > From: Tim Ward [mailto:[EMAIL PROTECTED]] > Sent: Thursday, June 13, 2002 4:18 AM > To: Martin Towell; Tom Rogers; Php; Phillip Perry > Subject: RE: [PHP] beginner in PHP > > > From the symptoms it sounds like you're destroying the session okay but > leaving the variables > In the script. Are you sure you're unsetting them at the appropriate scope > level. > > Tim Ward > www.chessish.com <http://www.chessish.com> > > -- > From: Phillip Perry [SMTP:[EMAIL PROTECTED]] > Sent: 13 June 2002 05:18 > To: Martin Towell; Tom Rogers; Php > Subject: RE: [PHP] beginner in PHP > > Thanks Martin!! That really helped out a lot. And thanks to all who > tried to > help me. I appreciate it! > > I have one other question that is really not so much important as it > is > annoying, but I can't figure it out myself. > > I'm practicing with sessions. What I'm making..if you couldn't tell > by the > array output from before...is a test shopping cart. Now the > annoyance is > that when I click the checkout link it's just supposed to destroy > the > session and reset everything to 0 including the shopping cart. And > also if > an item is clicked, that item gets deleted. With both choices when I > click > once the session does get destroyed, but everything stays on the > page until > I refresh the page. I want the info to get reset when I click the > link. > Here's the delete and checkout code...remember they both do actually > work, > just not as I want. Any suggestions on how to make it refresh on a > click > only? > > / DELETE SHOPPING CART ITEMS > > function chout(){ > session_destroy(); > $mycart = array(); > $cart_items = 0; > echo "Thank you for shopping!"; > } > > if ($action == delnow) > { > unset($mycart[$itemid]); > } > > // END DELETE SHOPPING CART ITEMS > > if ($action == checkout) > { > chout(); > } > > -Original Message- > From: Martin Towell [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 12, 2002 11:55 PM > To: '[EMAIL PROTECTED]'; Tom Rogers; Php > Subject: RE: [PHP] beginner in PHP > > > 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 PR
RE: [PHP] beginner in PHP
You're insetting the variables within the chout() function only This has no effect on the local copies as they are not in scope here. You have successfully destroyed the session so when you refresh they are unset. What I do with sessions is keep them all within a session array so you can then destroy the session locally by unsetting that array. If I have a function that I want to change session variables at all I make it take the session in as a parameter and pass it back as the return value. Tim Ward > -Original Message- > From: Phillip Perry [SMTP:[EMAIL PROTECTED]] > Sent: 13 June 2002 19:45 > To: Tim Ward; Martin Towell; Tom Rogers; Php > Subject: RE: [PHP] beginner in PHP > > Yes, here is the checkout code I used... > > function chout(){ > session_destroy(); > unset ($mycart); > unset ($cart_items); > echo "Thank you for shopping!"; > } > > Any suggestions? > > -Original Message- > From: Tim Ward [mailto:[EMAIL PROTECTED]] > Sent: Thursday, June 13, 2002 4:18 AM > To: Martin Towell; Tom Rogers; Php; Phillip Perry > Subject: RE: [PHP] beginner in PHP > > > From the symptoms it sounds like you're destroying the session okay but > leaving the variables > In the script. Are you sure you're unsetting them at the appropriate scope > level. > > Tim Ward > www.chessish.com <http://www.chessish.com> > > -- > From: Phillip Perry [SMTP:[EMAIL PROTECTED]] > Sent: 13 June 2002 05:18 > To: Martin Towell; Tom Rogers; Php > Subject: RE: [PHP] beginner in PHP > > Thanks Martin!! That really helped out a lot. And thanks to all who > tried to > help me. I appreciate it! > > I have one other question that is really not so much important as it > is > annoying, but I can't figure it out myself. > > I'm practicing with sessions. What I'm making..if you couldn't tell > by the > array output from before...is a test shopping cart. Now the > annoyance is > that when I click the checkout link it's just supposed to destroy > the > session and reset everything to 0 including the shopping cart. And > also if > an item is clicked, that item gets deleted. With both choices when I > click > once the session does get destroyed, but everything stays on the > page until > I refresh the page. I want the info to get reset when I click the > link. > Here's the delete and checkout code...remember they both do actually > work, > just not as I want. Any suggestions on how to make it refresh on a > click > only? > > / DELETE SHOPPING CART ITEMS > > function chout(){ > session_destroy(); > $mycart = array(); > $cart_items = 0; > echo "Thank you for shopping!"; > } > > if ($action == delnow) > { > unset($mycart[$itemid]); > } > > // END DELETE SHOPPING CART ITEMS > > if ($action == checkout) > { > chout(); > } > > -Original Message- > From: Martin Towell [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 12, 2002 11:55 PM > To: '[EMAIL PROTECTED]'; Tom Rogers; Php > Subject: RE: [PHP] beginner in PHP > > > 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 >
RE: Re[2]: [PHP] beginner in PHP
Thank you but that didn't work. I still have to refresh the page. -Original Message- From: Stuart Dallas [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 2:53 PM To: Phillip Perry Cc: Tim Ward; Martin Towell; Tom Rogers; Php Subject: Re[2]: [PHP] beginner in PHP On Thursday, June 13, 2002 at 7:44:39 PM, you wrote: > Yes, here is the checkout code I used... > function chout(){ > session_destroy(); > unset ($mycart); > unset ($cart_items); > echo "Thank you for shopping!"; > } > Any suggestions? Try this... function chout(){ global $mycart, $cart_items; session_destroy(); unset ($mycart); unset ($cart_items); echo "Thank you for shopping!"; } And if it works, read this: http://www.php.net/manual/en/language.variables.scope.php -- Stuart -- 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
Re[2]: [PHP] beginner in PHP
On Thursday, June 13, 2002 at 7:44:39 PM, you wrote: > Yes, here is the checkout code I used... > function chout(){ > session_destroy(); > unset ($mycart); > unset ($cart_items); > echo "Thank you for shopping!"; > } > Any suggestions? Try this... function chout(){ global $mycart, $cart_items; session_destroy(); unset ($mycart); unset ($cart_items); echo "Thank you for shopping!"; } And if it works, read this: http://www.php.net/manual/en/language.variables.scope.php -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] beginner in PHP
Yes, here is the checkout code I used... function chout(){ session_destroy(); unset ($mycart); unset ($cart_items); echo "Thank you for shopping!"; } Any suggestions? -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 4:18 AM To: Martin Towell; Tom Rogers; Php; Phillip Perry Subject: RE: [PHP] beginner in PHP >From the symptoms it sounds like you're destroying the session okay but leaving the variables In the script. Are you sure you're unsetting them at the appropriate scope level. Tim Ward www.chessish.com <http://www.chessish.com> -- From: Phillip Perry [SMTP:[EMAIL PROTECTED]] Sent: 13 June 2002 05:18 To: Martin Towell; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP Thanks Martin!! That really helped out a lot. And thanks to all who tried to help me. I appreciate it! I have one other question that is really not so much important as it is annoying, but I can't figure it out myself. I'm practicing with sessions. What I'm making..if you couldn't tell by the array output from before...is a test shopping cart. Now the annoyance is that when I click the checkout link it's just supposed to destroy the session and reset everything to 0 including the shopping cart. And also if an item is clicked, that item gets deleted. With both choices when I click once the session does get destroyed, but everything stays on the page until I refresh the page. I want the info to get reset when I click the link. Here's the delete and checkout code...remember they both do actually work, just not as I want. Any suggestions on how to make it refresh on a click only? / DELETE SHOPPING CART ITEMS function chout(){ session_destroy(); $mycart = array(); $cart_items = 0; echo "Thank you for shopping!"; } if ($action == delnow) { unset($mycart[$itemid]); } // END DELETE SHOPPING CART ITEMS if ($action == checkout) { chout(); } -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 11:55 PM To: '[EMAIL PROTECTED]'; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP 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 "".print_r($catalogue)."".print_r($mycart).""; 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
>From the symptoms it sounds like you're destroying the session okay but leaving the variables In the script. Are you sure you're unsetting them at the appropriate scope level. Tim Ward www.chessish.com <http://www.chessish.com> -- From: Phillip Perry [SMTP:[EMAIL PROTECTED]] Sent: 13 June 2002 05:18 To: Martin Towell; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP Thanks Martin!! That really helped out a lot. And thanks to all who tried to help me. I appreciate it! I have one other question that is really not so much important as it is annoying, but I can't figure it out myself. I'm practicing with sessions. What I'm making..if you couldn't tell by the array output from before...is a test shopping cart. Now the annoyance is that when I click the checkout link it's just supposed to destroy the session and reset everything to 0 including the shopping cart. And also if an item is clicked, that item gets deleted. With both choices when I click once the session does get destroyed, but everything stays on the page until I refresh the page. I want the info to get reset when I click the link. Here's the delete and checkout code...remember they both do actually work, just not as I want. Any suggestions on how to make it refresh on a click only? / DELETE SHOPPING CART ITEMS function chout(){ session_destroy(); $mycart = array(); $cart_items = 0; echo "Thank you for shopping!"; } if ($action == delnow) { unset($mycart[$itemid]); } // END DELETE SHOPPING CART ITEMS if ($action == checkout) { chout(); } -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 11:55 PM To: '[EMAIL PROTECTED]'; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP 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 "".print_r($catalogue)."".print_r($mycart).""; 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? > &g
RE: [PHP] beginner in PHP
I get the same thing...I have to click twice, or refresh the page to get rid of the info. -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 12:21 AM To: '[EMAIL PROTECTED]'; Php Subject: RE: [PHP] beginner in PHP try this for chout() function chout(){ global $mycart, $cart_items; session_destroy(); -Original Message- From: Phillip Perry [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 2:18 PM To: Martin Towell; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP Thanks Martin!! That really helped out a lot. And thanks to all who tried to help me. I appreciate it! I have one other question that is really not so much important as it is annoying, but I can't figure it out myself. I'm practicing with sessions. What I'm making..if you couldn't tell by the array output from before...is a test shopping cart. Now the annoyance is that when I click the checkout link it's just supposed to destroy the session and reset everything to 0 including the shopping cart. And also if an item is clicked, that item gets deleted. With both choices when I click once the session does get destroyed, but everything stays on the page until I refresh the page. I want the info to get reset when I click the link. Here's the delete and checkout code...remember they both do actually work, just not as I want. Any suggestions on how to make it refresh on a click only? / DELETE SHOPPING CART ITEMS function chout(){ session_destroy(); $mycart = array(); $cart_items = 0; echo "Thank you for shopping!"; } if ($action == delnow) { unset($mycart[$itemid]); } // END DELETE SHOPPING CART ITEMS if ($action == checkout) { chout(); } -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 11:55 PM To: '[EMAIL PROTECTED]'; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP 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 "".print_r($catalogue)."".print_r($mycart).""; 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 > > >-- >
RE: [PHP] beginner in PHP
try this for chout() function chout(){ global $mycart, $cart_items; session_destroy(); -Original Message- From: Phillip Perry [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 2:18 PM To: Martin Towell; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP Thanks Martin!! That really helped out a lot. And thanks to all who tried to help me. I appreciate it! I have one other question that is really not so much important as it is annoying, but I can't figure it out myself. I'm practicing with sessions. What I'm making..if you couldn't tell by the array output from before...is a test shopping cart. Now the annoyance is that when I click the checkout link it's just supposed to destroy the session and reset everything to 0 including the shopping cart. And also if an item is clicked, that item gets deleted. With both choices when I click once the session does get destroyed, but everything stays on the page until I refresh the page. I want the info to get reset when I click the link. Here's the delete and checkout code...remember they both do actually work, just not as I want. Any suggestions on how to make it refresh on a click only? / DELETE SHOPPING CART ITEMS function chout(){ session_destroy(); $mycart = array(); $cart_items = 0; echo "Thank you for shopping!"; } if ($action == delnow) { unset($mycart[$itemid]); } // END DELETE SHOPPING CART ITEMS if ($action == checkout) { chout(); } -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 11:55 PM To: '[EMAIL PROTECTED]'; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP 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 "".print_r($catalogue)."".print_r($mycart).""; 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:
RE: [PHP] beginner in PHP
Thanks Martin!! That really helped out a lot. And thanks to all who tried to help me. I appreciate it! I have one other question that is really not so much important as it is annoying, but I can't figure it out myself. I'm practicing with sessions. What I'm making..if you couldn't tell by the array output from before...is a test shopping cart. Now the annoyance is that when I click the checkout link it's just supposed to destroy the session and reset everything to 0 including the shopping cart. And also if an item is clicked, that item gets deleted. With both choices when I click once the session does get destroyed, but everything stays on the page until I refresh the page. I want the info to get reset when I click the link. Here's the delete and checkout code...remember they both do actually work, just not as I want. Any suggestions on how to make it refresh on a click only? / DELETE SHOPPING CART ITEMS function chout(){ session_destroy(); $mycart = array(); $cart_items = 0; echo "Thank you for shopping!"; } if ($action == delnow) { unset($mycart[$itemid]); } // END DELETE SHOPPING CART ITEMS if ($action == checkout) { chout(); } -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 11:55 PM To: '[EMAIL PROTECTED]'; Tom Rogers; Php Subject: RE: [PHP] beginner in PHP 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 "".print_r($catalogue)."".print_r($mycart).""; 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
RE: [PHP] beginner in PHP
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 "".print_r($catalogue)."".print_r($mycart).""; 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
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 "".print_r($catalogue)."".print_r($mycart).""; 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
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 "".print_r($catalogue)."".print_r($mycart).""; 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
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 "".print_r($catalogue)."".print_r($mycart).""; 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
RE: [PHP] beginner in PHP
Array ( [0] => gerainiums [1] => roses [2] => roses [3] => roses [4] => roses ) Array ( [0] => Array ( [itemcd] => daisys [itemcat] => FL [itemdesc] => Daisys, seed package 200/250 cnt [unitprice] => 2.2 ) [1] => Array ( [itemcd] => gerainiums [itemcat] => FL [itemdesc] => Gerainiums, purple, seed package 25/30 cnt [unitprice] => 0.85 ) [2] => Array ( [itemcd] => roses [itemcat] => FL [itemdesc] => Rose, white, root clump bush - spring delivery [unitprice] => 35 ) [3] => Array ( [itemcd] => tomatoe [itemcat] => VG [itemdesc] => Tomatoe, Super-Burbee, seedling flat, 12 plants [unitprice] => 12.5 ) [4] => Array ( [itemcd] => cucumber [itemcat] => VG [itemdesc] => Cucumber seed package, Chyrnobyl hybrid cross 10cnt [unitprice] => 0.03 ) [5] => Array ( [itemcd] => habanero [itemcat] => HP [itemdesc] => Red Savina Habanero Pepper seeds -- 20cnt, not for export [unitprice] => 2.85 ) [6] => Array ( [itemcd] => snapdragon [itemcat] => FL [itemdesc] => Snap Dragons, yellow/orange mix, seed package 50cnt [unitprice] => 1.25 ) [7] => Array ( [itemcd] => tulip [itemcat] => FL [itemdesc] => Tulip bulbs ... spring delivery 8 sets [unitprice] => 42.5 ) [8] => Array ( [itemcd] => snappea [itemcat] => VG [itemdesc] => Sugar snap peas - seed package 25 count [unitprice] => 2 ) [9] => Array ( [itemcd] => marigold [itemcat] => FL [itemdesc] => Marigold - Traditional ... seed package 40 cnt [unitprice] => 3.15 ) [10] => Array ( [itemcd] => bellpepper [itemcat] => VG [itemdesc] => Green Bell Pepper - Sweet, seed package 30 cnt [unitprice] => 4 ) [11] => Array ( [itemcd] => tigerlilly [itemcat] => FL [itemdesc] => Tiger Lilly seedlings 10cnt [unitprice] => 5.2 ) [12] => Array ( [itemcd] => pequin [itemcat] => HP [itemdesc] => Pequin ornamental hot pepper seed, 150 count [unitprice] => 4.25 ) [13] => Array ( [itemcd] => seranno [itemcat] => HP [itemdesc] => Seranno Pepper - spicy! seed pack 42cnt [unitprice] => 1.25 ) [14] => Array ( [itemcd] => flamingo [itemcat] => LO [itemdesc] => Tacky plastic pink flamingo, each [unitprice] => 5.23 ) [15] => Array ( [itemcd] => stork [itemcat] => LO [itemdesc] => Tacky plastic stork, alienate the new mom! each [unitprice] => 7.25 ) [16] => Array ( [itemcd] => rabbit [itemcat] => LO [itemdesc] => Plastic lawn rabbit, multiplies less than real, each [unitprice] => 4.05 ) [17] => Array ( [itemcd] => barney [itemcat] => LO [itemdesc] => Barney the Giant Purple Dinosaur, take him please! [unitprice] => 0.25 ) [18] => Array ( [itemcd] => gargoyle [itemcat] => LO [itemdesc] => Gargoyle, plaster, for the goth in us all! [unitprice] => 25 ) ) -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 11:33 PM To: '[EMAIL PROTECTED]'; Php Subject: RE: [PHP] beginner in PHP send the results of putting these two line just before your while loop print_r($mycart); print_r($catalog); -Original Message- From: Phillip Perry [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 1:31 PM To: Tom Rogers; Php Subject: RE: [PHP] beginner in PHP 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
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 "".print_r($catalogue)."".print_r($mycart).""; 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
RE: [PHP] beginner in PHP
send the results of putting these two line just before your while loop print_r($mycart); print_r($catalog); -Original Message- From: Phillip Perry [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 1:31 PM To: Tom Rogers; Php Subject: RE: [PHP] beginner in PHP 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
RE: [PHP] beginner in PHP
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
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
RE: [PHP] beginner in PHP
Thanks but that doesn't work. -Original Message- From: Tom Ray [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 10:59 PM To: [EMAIL PROTECTED] Cc: Php Subject: Re: [PHP] beginner in PHP Try this: echo "$catalog[unitprice]"; in my experience I've only been able to use the echo() without the quotation marks if I'm calling a function, for variables you need the quotation marks. Hope this helps. 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
RE: [PHP] beginner in PHP
itemcd is an element of the array.. like this... array ('itemcd' => 'book', 'itemdesc' => 'This book is great', 'unitprice' => '29.95'); -Original Message- From: Pushkar Pradhan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 11:12 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] beginner in PHP Is itemcd a variable then it should be used as $itemcd? > Try this: > > echo "$catalog[unitprice]"; > > > in my experience I've only been able to use the echo() without the > quotation marks if I'm calling a function, for variables you need the > quotation marks. > > Hope this helps. > > > 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 > -Pushkar S. Pradhan -- 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
Re: [PHP] beginner in PHP
Is itemcd a variable then it should be used as $itemcd? > Try this: > > echo "$catalog[unitprice]"; > > > in my experience I've only been able to use the echo() without the > quotation marks if I'm calling a function, for variables you need the > quotation marks. > > Hope this helps. > > > 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 > -Pushkar S. Pradhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginner in PHP
Try this: echo "$catalog[unitprice]"; in my experience I've only been able to use the echo() without the quotation marks if I'm calling a function, for variables you need the quotation marks. Hope this helps. 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] beginner in PHP
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
Re: [PHP] Editors, again (was Re: [PHP] Beginner in php!)
That is a very useful looking link and it has gone into to my "very useful PHP links" box. I will point out that "codecharge" and "phpedit" don't appear to be on that list ... At 06:19 AM 1/24/01 -0800, Steve Edberg wrote: >At 4:40 PM +0600 1/24/01, Tshering Norbu wrote: >>Here is collection I got from this list; >> >>www.editplus.com >>www.codecharge.com >>www.phpedit.com >>www.ultraedit.com > >See this list: > > http://www.itworks.demon.co.uk/phpeditors.htm > >Some of the comments are a bit out of date - for instance, BBEdit 6.0 >(Macintosh) now has PHP syntax highlighting - but it's a got starting point. > > - steve > > >> >>- Original Message - >>From: kaab kaoutar <[EMAIL PROTECTED]> >>To: <[EMAIL PROTECTED]> >>Sent: Wednesday, January 24, 2001 4:28 PM >>Subject: [PHP] Beginner in php! >> >> >>> Hi guys! >>> >>> I'm working on an NT workstation, i used to work with asp, but i heard a >>lot >>> about php! that i decided to start working with it ! >>> so i'm using PWS4 and i'm wondering which free php editor is more suitible >>> for me ? and also what links to get free more tutorials, i got one of >>phpnet >>> but still >>> >>> Regards >>> _ >> > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > >-- >+--- "They've got a cherry pie there, that'll kill ya" --+ >| Steve Edberg University of California, Davis | >| [EMAIL PROTECTED] Computer Consultant | >| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | >+-- FBI Special Agent Dale Cooper ---+ > >-- >PHP General 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] - Brian White Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: [EMAIL PROTECTED] -- PHP General 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] Editors, again (was Re: [PHP] Beginner in php!)
At 4:40 PM +0600 1/24/01, Tshering Norbu wrote: >Here is collection I got from this list; > >www.editplus.com >www.codecharge.com >www.phpedit.com >www.ultraedit.com > See this list: http://www.itworks.demon.co.uk/phpeditors.htm Some of the comments are a bit out of date - for instance, BBEdit 6.0 (Macintosh) now has PHP syntax highlighting - but it's a got starting point. - steve > >- Original Message - >From: kaab kaoutar <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Wednesday, January 24, 2001 4:28 PM >Subject: [PHP] Beginner in php! > > >> Hi guys! >> >> I'm working on an NT workstation, i used to work with asp, but i heard a >lot >> about php! that i decided to start working with it ! >> so i'm using PWS4 and i'm wondering which free php editor is more suitible >> for me ? and also what links to get free more tutorials, i got one of >phpnet >> but still >> >> Regards >> _ > > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. >> -- +--- "They've got a cherry pie there, that'll kill ya" --+ | Steve Edberg University of California, Davis | | [EMAIL PROTECTED] Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-- FBI Special Agent Dale Cooper ---+ -- PHP General 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]
RE: [PHP] Beginner in php!
Hi, welcome to the wonderful world of PHP... You can use any text editor you like to write your PHP, my personal favourite is EditPlus 2 (www.editplus.com), but this is holy war territory so try a few out and see which one you get on with best. There are loads of great tutorials all over the www, IMHO you could do a lot worse than starting off at Webmonkey (http://hotwired.lycos.com/webmonkey/programming/php/) where there are a shedload of articles to do with loads of different aspects of PHP. If you're using NT Workstation and you're currently stuck with PWS (a big pile of sh*te), you might want to have a look at Apache (www.apache.org) which is considerably better. For databases, I'd heartily recommend MySQL (www.mysql.com). This combination - Apache/PHP/MySQL - is used by a huge number of websites and the support is superb from the open source community. The best thing about the whole lot is it's easy to persuade management to go for projects where the overall price tag is £0.00! HTH Jon -Original Message- From: kaab kaoutar [mailto:[EMAIL PROTECTED]] Sent: 24 January 2001 10:29 To: [EMAIL PROTECTED] Subject: [PHP] Beginner in php! Hi guys! I'm working on an NT workstation, i used to work with asp, but i heard a lot about php! that i decided to start working with it ! so i'm using PWS4 and i'm wondering which free php editor is more suitible for me ? and also what links to get free more tutorials, i got one of phpnet but still Regards _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- PHP General 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 General 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]
Re: [PHP] Beginner in php!
Here is collection I got from this list; www.editplus.com www.codecharge.com www.phpedit.com www.ultraedit.com NOBBY - Original Message - From: kaab kaoutar <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 24, 2001 4:28 PM Subject: [PHP] Beginner in php! > Hi guys! > > I'm working on an NT workstation, i used to work with asp, but i heard a lot > about php! that i decided to start working with it ! > so i'm using PWS4 and i'm wondering which free php editor is more suitible > for me ? and also what links to get free more tutorials, i got one of phpnet > but still > > Regards > _ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > > -- > PHP General 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 General 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] Beginner in php!
Hi guys! I'm working on an NT workstation, i used to work with asp, but i heard a lot about php! that i decided to start working with it ! so i'm using PWS4 and i'm wondering which free php editor is more suitible for me ? and also what links to get free more tutorials, i got one of phpnet but still Regards _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- PHP General 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]