Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators

2010-03-03 Thread clancy_1
On Wed, 3 Mar 2010 08:21:06 -0600, halip...@gmail.com (haliphax) wrote: >> On Fri, Feb 26, 2010 at 11:01 PM, wrote: >> > while ($i < $j) { $b[$i] = $a[$i++]; } B. >> > >> > You get $b[0] = $a[1], and so on (as you would expect). >> > >Wouldn't that be $b[0] = $a[0], with the value of $i

Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators

2010-03-03 Thread haliphax
> On Fri, Feb 26, 2010 at 11:01 PM, wrote: > > while ($i < $j) { $b[$i] = $a[$i++]; } B. > > > > You get $b[0] = $a[1], and so on (as you would expect). > Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the statement was finished executing? You used a post-decrement

Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators

2010-03-02 Thread Adam Richardson
Thanks for taking time to provide the examples, Clancy, I'll know what potential pitfalls to wary of now :) On Fri, Feb 26, 2010 at 11:01 PM, wrote: > A week ago Dasn asked a question about converting arrays, and I quoted one > possible way of > achieving his task, using the operation: > > $i =

[PHP] Re: PHP: inexplicable behaviour of pre- and post-increment operators

2010-03-01 Thread Martin Zvarík
Mess Dne 27.2.2010 5:01, clanc...@cybec.com.au napsal(a): A week ago Dasn asked a question about converting arrays, and I quoted one possible way of achieving his task, using the operation: $i = 0; while ($i< $k) { $b[$a[$i++]] = $a[$i++]; } I added the comment that "I have always been war

[PHP] PHP: inexplicable behaviour of pre- and post-increment operators

2010-02-26 Thread clancy_1
A week ago Dasn asked a question about converting arrays, and I quoted one possible way of achieving his task, using the operation: $i = 0; while ($i < $k) { $b[$a[$i++]] = $a[$i++]; } I added the comment that "I have always been wary of using statements like this because I was unsure when the

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-28 Thread 9el
> >> $Count = $Count + 1; is *exactly(?)* same as $Count++; Â or ++$Count > >> But not exactly same. Â PostFix notation adds the value after assigning > . > >> PreFix notation adds the value right away. > >> But optimized programming argues about how machine is coded nowadays. > Thanks Mike for cl

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-28 Thread PJ
Ford, Mike wrote: > On 27 April 2009 14:21, PJ advised: > > >> Ford, Mike wrote: >> >>> On 26 April 2009 22:59, PJ advised: >>> >>> >>> kranthi wrote: > if $Count1 is never referenced after this, then certainly this > assignment operation is redundent.

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-28 Thread PJ
Richard Quadling wrote: > 2009/4/27 9el : > >>> Thanks for the clarification, Mike. In my ignorance, I was under the >>> impression that the right side of the equation was only for the use of >>> the left part. How stupid of me. So what I should have been doing was >>> $Count1 = $Count + 1; righ

RE: RES: [PHP] inexplicable behaviour SOLVED

2009-04-28 Thread Ford, Mike
On 27 April 2009 14:21, PJ advised: > Ford, Mike wrote: >> On 26 April 2009 22:59, PJ advised: >> >> >>> kranthi wrote: >>> if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-28 Thread 9el
Thats why I used a (?) after exactly. PJ didn't have a need for the value. ;)

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-28 Thread Richard Quadling
2009/4/27 9el : >> >> Thanks for the clarification, Mike. In my ignorance, I was under the >> impression that the right side of the equation was only for the use of >> the left part. How stupid of me. So what I should have been doing was >> $Count1 = $Count + 1; right? >> $Count1 = $Count++; is n

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-27 Thread 9el
> > Thanks for the clarification, Mike. In my ignorance, I was under the > impression that the right side of the equation was only for the use of > the left part. How stupid of me. So what I should have been doing was > $Count1 = $Count + 1; right? > $Count = $Count + 1; is exactly(?) same as $Coun

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-27 Thread PJ
Ford, Mike wrote: > On 26 April 2009 22:59, PJ advised: > > >> kranthi wrote: >> >>> if $Count1 is never referenced after this, then certainly this >>> assignment operation is redundent. but assignment is not the ONLY >>> operation of this statement. if u hav not noticed a post increment >>

Re: [PHP] inexplicable behaviour

2009-04-27 Thread Simon
If you want to increment $Count by one, you can use any one of the 3 following lines to do this: $Count = $Count + 1; $Count += 1; $Count++; The 3 lines are equivalent, but have varying degrees of elegance (suit yourself). However, make sure that your mysql function returned a number (and not an er

RE: RES: [PHP] inexplicable behaviour SOLVED

2009-04-27 Thread Ford, Mike
On 26 April 2009 22:59, PJ advised: > kranthi wrote: >> if $Count1 is never referenced after this, then certainly this >> assignment operation is redundent. but assignment is not the ONLY >> operation of this statement. if u hav not noticed a post increment >> operator has been used which will aff

Re: RES: [PHP] inexplicable behaviour

2009-04-26 Thread PJ
Phpster wrote: > What parameters are you pasing in the link? That will be the telling > point of what you are doing wrong. You could pass the search params ( > though these are best kept in a session or cookie ) and the offset > counter to get the next block of results. Actually, I am trying to use

Re: RES: [PHP] inexplicable behaviour

2009-04-26 Thread PJ
> Look for "Pagination with PHP + MySQL" and watchit > > > http://www.google.com/url?sa=t&source=web&ct=res&cd=10&url=http%3A%2F%2Fwww.bestechvideos.com%2F2008%2F07%2F02%2Fsampsonvideos-php-pagination-part-2&ei=ohn0SdnlL8KLkAWQrNTbCg&usg=AFQjCNEGKOIG3791BpgeVqCiiq5-cikbRA > > Dont miss this Sampso

Re: RES: [PHP] inexplicable behaviour

2009-04-26 Thread PJ
9el wrote: > I have pagination set up and the number for pages "next" has a link but > the "next" does not. I have experimented with all sorts of > configurations of the code but the only thing that works (and this is > totally "off the wall") is to do this > *$Count* = *mysql_num_rows($results);*

Re: RES: [PHP] inexplicable behaviour SOLVED

2009-04-26 Thread PJ
kranthi wrote: > if $Count1 is never referenced after this, then certainly this > assignment operation is redundent. but assignment is not the ONLY > operation of this statement. if u hav not noticed a post increment > operator has been used which will affect the value of $Count as well, > and this

Re: RES: [PHP] inexplicable behaviour

2009-04-26 Thread Phpster
What parameters are you pasing in the link? That will be the telling point of what you are doing wrong. You could pass the search params ( though these are best kept in a session or cookie ) and the offset counter to get the next block of results. Sorry for top posting. Bastien Sent from

Re: RES: [PHP] inexplicable behaviour

2009-04-26 Thread 9el
I have pagination set up and the number for pages "next" has a link but the "next" does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally "off the wall") is to do this *$Count* = *mysql_num_rows($results);* $Count1=*$Count++;* /

Re: RES: [PHP] inexplicable behaviour

2009-04-25 Thread kranthi
if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement. if u hav not noticed a post increment operator has been used which will affect the value of $Count as well, and this operation is required fo

Re: RES: [PHP] inexplicable behaviour

2009-04-25 Thread PJ
otron.ca] > Enviada em: sexta-feira, 24 de abril de 2009 21:14 > Para: php-general@lists.php.net > Assunto: [PHP] inexplicable behaviour > > Frankly, I don't know what to look for or why something so weird would > happen: > I have pagination set up and the number for page

RES: [PHP] inexplicable behaviour

2009-04-24 Thread Jônatas Zechim
Is the $Count++.. -Mensagem original- De: PJ [mailto:af.gour...@videotron.ca] Enviada em: sexta-feira, 24 de abril de 2009 21:14 Para: php-general@lists.php.net Assunto: [PHP] inexplicable behaviour Frankly, I don't know what to look for or why something so weird would happen: I

[PHP] inexplicable behaviour

2009-04-24 Thread PJ
Frankly, I don't know what to look for or why something so weird would happen: I have pagination set up and the number for pages "next" has a link but the "next" does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally "off the wa