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 4 of 4

Thread: $_GET["name"]

  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts

    $_GET["name"]

    in a simple $_get from a form, how would I do something like this that works:

    $_GET["Question0+($txt)"]

    The name of the form field(s) is Question0# and there will be alot so im using variables that increase inbetween each question so that I dont have to change it myself.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    You would be better off naming your variables in your html as arrays so that you can use
    $_GET['Question'][0] etc

    You could use
    $_GET['Question'.$i.'#'];
    i suppose. It all depends on the context of your use
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • Users who have thanked JAY6390 for this post:

    Ndogg (01-24-2010)

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    Or I could acually just do this

    $_GET['Question0'.$txt]

    I did that once but with quotes so I guess thats why it didnt work, thanks though

  • #4
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Or you could just do as Jay suggested and increment it automatically without any phaffing, and use an array for the values.

    Code:
    $x = 0;
    
    [rest of code here]
    
    $_GET['Question'][$x++];
    Last edited by MattF; 01-24-2010 at 04:55 PM.


  •  

    Posting Permissions

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