Re: [PHP] session_name("CCLTrolley")

2005-10-04 Thread Jasper Bryant-Greene
John Taylor-Johnston wrote: I ended up going with this. Wasn't sure how to use list anyhow. Look good? $sql = 'SELECT * FROM '.$table.' ORDER BY RNum;'; echo ""; $news = mysql_query($sql); while ($mydata = mysql_fetch_object($news)) { foreach ($_SESSION['TrolleyContents'] as $value) if

Re: [PHP] session_name("CCLTrolley")

2005-10-04 Thread John Taylor-Johnston
Robert Cummings wrote: On Mon, 2005-10-03 at 18:08, John Taylor-Johnston wrote: >Use "foreach" to traverse the array and display each trolly entry nicely If list() works for you it's fine. I don't really use it so not entirely sure of it's functionality with respect to looping. I

Re: [PHP] session_name("CCLTrolley")

2005-10-04 Thread Robert Cummings
On Mon, 2005-10-03 at 18:08, John Taylor-Johnston wrote: > >Use "foreach" to traverse the array and display each trolly entry nicely > > This might be cleaner? I'm not sure if I'm using while and list right, > but somehting like that? > > $glquery = mysql_query($sql); > while ($mydata = mysql_f

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston
>Use "foreach" to traverse the array and display each trolly entry nicely This might be cleaner? I'm not sure if I'm using while and list right, but somehting like that? $glquery = mysql_query($sql); while ($mydata = mysql_fetch_object($glquery)) { while (list($_SESSION['TrolleyContents'], $

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston
In the search results, I use something longwinded: You are talking about doing this, below. It looks a little clunky, doesn't it? foreach ($_SESSION['TrolleyContents'] as $value) { $sql = "select * where RNum= $value"; $news = mysql_query($sql1) or die ... while ($mydata = mysql_fetch_ob

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Mon, 2005-10-03 at 16:38, John Taylor-Johnston wrote: > Robert Cummings wrote: > >I took a look at your link and it appears to be working fine, though you > >haven't yet wired up the viewcart.php > > When I create viewcart.php, what is the best way to extract and display > the contents of $_

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston
Robert Cummings wrote: >I took a look at your link and it appears to be working fine, though you >haven't yet wired up the viewcart.php When I create viewcart.php, what is the best way to extract and display the contents of $_SESSION['TrolleyContents'] ? Do I use my $sql value? or in my while

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Mon, 2005-10-03 at 14:51, John Taylor-Johnston wrote: > Is that over kill? No matter how I slam it, still referring to my > Frankensteinian merge, "unset" does the job. > http://testesp.flsh.usherbrooke.ca/db/trolley.php > But then again, I will not require a quanity of items. The visitor will

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston
Is that over kill? No matter how I slam it, still referring to my Frankensteinian merge, "unset" does the job. http://testesp.flsh.usherbrooke.ca/db/trolley.php But then again, I will not require a quanity of items. The visitor will only want one copy of a bibliographic entry :-\ - I hope?! You

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Mon, 2005-10-03 at 14:11, John Taylor-Johnston wrote: > Excellent. Thanks. I think I follow what you have done. But to > clarify, and learn, what are you doing with -= ? > $trolley[$item] -= $quantity; > Likewise, i had not followed what you were doing with the lines I > commented out. They did

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston
Excellent. Thanks. I think I follow what you have done. But to clarify, and learn, what are you doing with -= ? $trolley[$item] -= $quantity; Likewise, i had not followed what you were doing with the lines I commented out. They did not seem to work, and I succeeded in doing what I wanted withou

Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Sun, 2005-10-02 at 01:01, Robert Cummings wrote: > > If you go with an array system might I suggest the following change to > what I wrote: I'm resending a better way to do the simple trolley since you seemed to have created a Frankensteinian merge of the two examples I sent previously. This ve

Re: [PHP] session_name("CCLTrolley")

2005-10-02 Thread John Taylor-Johnston
This is what you recommended. Is there a reason you're using a comma delimited string? I would recommend using an array instead: This is what I implemented? Where did I go wrong? John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] session_name("CCLTrolley")

2005-10-02 Thread John Taylor-Johnston
>This is the old version I demonstrated. You should go with the later >version that sets the values to the quantity :) I thought I had? Haven't I? But this is the easiest shopping cart I have ever seen. However, I still have not understood what you were doing with these lines I commented out.

Re: [PHP] session_name("CCLTrolley")

2005-10-02 Thread Robert Cummings
On Mon, 2005-10-03 at 00:16, John Taylor-Johnston wrote: > >Warning: Bad arguments to implode() in /var/.../printtrolley.php on > line 14 > >Array ( [TrolleyContents] => 1 3 4 4 5 6 ) > > I restarted Mozilla and tried again. > It's ok now. > Thanks for your time. The old session was probably s

Re: [PHP] session_name("CCLTrolley")

2005-10-02 Thread John Taylor-Johnston
>Warning: Bad arguments to implode() in /var/.../printtrolley.php on line 14 >Array ( [TrolleyContents] => 1 3 4 4 5 6 ) I restarted Mozilla and tried again. It's ok now. Thanks for your time. Array ( [TrolleyContents] => Array ( [16] => 16 [30] => 30

Re: [PHP] session_name("CCLTrolley")

2005-10-02 Thread John Taylor-Johnston
Robert Cummings wrote: Is there a reason you're using a comma delimited string? I would recommend using an array instead: Cheers, Rob. Hi, Still absorbing this array stuff :). I'm getting this error. And when RNum = 1 or = 16 or = 116, it only registers '1', or whatever the first digit

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread John Taylor-Johnston
Robert Cummings wrote: To decrement the quantity of an item in the trolley: RNum] ) ) { $_SESSION['TrolleyContents'][$myData->RNum] -= 1; if( $_SESSION['TrolleyContents'][$myData->RNum] <= 0 ) { unset( $_SESSION['TrolleyContents'][$myData->RNum] ); } } ?> I'll leave it as an e

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread Robert Cummings
On Sun, 2005-10-02 at 00:37, John Taylor-Johnston wrote: > Robert Cummings wrote: > > > > session_name( 'CCLTrolley' ); > > session_start(); > > // Initialize the trolley. > > if( !isset( $_SESSION['TrolleyContents'] ) ) > > { > > $_SESSION['TrolleyContents'] = array(); > > } > > // Add new entry

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread Robert Cummings
On Sun, 2005-10-02 at 00:41, John Taylor-Johnston wrote: > Robert Cummings wrote: > > > And $_SESSION instead of session_register and always access your session > > vars through $_SESSION. > > I'm safe with "PHP Version 4.1.2" ? Should be. The docs state that the $_XXX series of vars were introd

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread John Taylor-Johnston
Robert Cummings wrote: And $_SESSION instead of session_register and always access your session vars through $_SESSION. I'm safe with "PHP Version 4.1.2" ? John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread John Taylor-Johnston
Robert Cummings wrote: $_SESSION['TrolleyContents'][$_POST['AddToTrolley']] = $_POST['AddToTrolley'] } echo implode( ',', $_SESSION['TrolleyContents'] ); ?> I've never been very good getting my head around arrays. Then how do I check to know if $mydata->RNum is in $_SESSION['TrolleyContents

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread Robert Cummings
On Sun, 2005-10-02 at 00:32, John Taylor-Johnston wrote: > > > > > session_name( 'CCLTrolley' ); > > session_start(); > > > > // > > // Initialize the trolley. > > // > > if( !isset( $_SESSION['TrolleyContents'] ) ) > > { > >$_SESSION['TrolleyContents'] = ''; > > } > > > > // > > // Add new en

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread John Taylor-Johnston
Robert Cummings wrote: John Taylor-Johnston wrote: Robert Cummings wrote: Why is it outdated semantics? Might i refer you to: http://ca.php.net/manual/en/language.variables.predefined.php http://ca.php.net/manual/en/function.session-register.php $HTTP_POST_VARS has been consid

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread Robert Cummings
On Sun, 2005-10-02 at 00:18, John Taylor-Johnston wrote: > > P.S. do folks prefer I reply on top or on bottom? Some people don't care, but those that do care have loud voices and would prefer you bottom post since they haven't yet been upgraded to random access reading and are still hooked up to a

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread Jasper Bryant-Greene
John Taylor-Johnston wrote: Looks a bit odd to me :) But could be because you're using outdated semantics. It should be sufficient to do the following: [snip] Why is it outdated semantics? I believe he was referring to your use of $HTTP_POST_VARS and session_register, which have been replac

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread Robert Cummings
On Sun, 2005-10-02 at 00:18, John Taylor-Johnston wrote: > Robert Cummings wrote: > > Why is it outdated semantics? > > P.S. do folks prefer I reply on top or on bottom? Might i refer you to: http://ca.php.net/manual/en/language.variables.predefined.php http://ca.php.net/manual/en/function.sess

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread John Taylor-Johnston
Robert Cummings wrote: On Sat, 2005-10-01 at 23:57, John Taylor-Johnston wrote: $TrolleyContents is a string. Basically what I want to accomplish here is if $TrolleyContents already exists append $AddToTrolley to $TrolleyContents, if not register $TrolleyContents. Am I going about it righ

Re: [PHP] session_name("CCLTrolley")

2005-10-01 Thread Robert Cummings
On Sat, 2005-10-01 at 23:57, John Taylor-Johnston wrote: > $TrolleyContents is a string. > Basically what I want to accomplish here is if $TrolleyContents already > exists append $AddToTrolley to $TrolleyContents, if not register > $TrolleyContents. > Am I going about it right? > John > > #prin