Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: +1? How!?!

  1. #1
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts

    +1? How!?!

    hi how do i plus 1 to a var eg

    PHP Code:
    <?php
    $curpg 
    $_GET['curpage'];
    $nxtpg ''// here is where i am stuck i want to do curpage +1 but i don't know how
    I have searched this in Google and it comes up with things like ' Adding PHP To A Webpage! '

    Please Help!

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    PHP Code:
    $curpg $_GET['curpage'];
    $nxtpg "$curpg++"
    this work?

  • #3
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    that just adds ++ to the end of my URL parameter
    Look:
    index.php?curpage=1++

  • #4
    New Coder
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 1 Time in 1 Post
    Is this question some kind of joke?

    Quote Originally Posted by rafiki View Post
    PHP Code:
    $curpg $_GET['curpage'];
    $nxtpg "$curpg++"
    this work?

    There's no need for those double quotes.

    This works:
    PHP Code:
    $curpg intval$_GET['curpage'] );
    $nxtpg $curpg 1

  • #5
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    cheers

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    To increment a number variable rafiki was correct you just need to use the ++ operator. Just lose the quotes around it otherwise it will treated as a string which is why you got the characters ++ at the end.

    $curpg = curpg + 1 is the same as $curpg++.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    ok sos!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •