www.url.com?id=1&id=3 issue

Discussion in 'PHP' started by timallard, Mar 2, 2009.

  1. #1
    Hello

    Im creating some dynamic links. each link is being called in from a table row and has its own unique id in mysql. the id is the primary way data is being pulled in from.


    lets say im looking at my page,. the url would be www.url.com?id=1
    when i click on a dynamic link below, it is giving me the new url of www.url.com?id=1&id=3 - its appending not updating


    any ideas how to solve this?

    Thanks
     
    timallard, Mar 2, 2009 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    what are you putting as the href for the links?
     
    shallowink, Mar 2, 2009 IP
  3. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #3
    <a href="loading-curiosity.php?<?php echo $queryString . "id=" . $row5['ID']; ?>">
     
    timallard, Mar 2, 2009 IP
  4. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #4
    ithink the issue is with the $queryString because its storing an ID already...
     
    timallard, Mar 2, 2009 IP
  5. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #5
    might need to check if query string already has the id and replace it. but think thats the 'right' way.

    why are you reusing the querystring? if there isn't a real good reason, drop it. also might depend on if you are using a script and on any other data you need to have outgoing.
    just test by assigning it to a temp variable then zero it out. after the routine restore it.
    Then you will have to determine where to go with it.
     
    shallowink, Mar 2, 2009 IP
    timallard likes this.
  6. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #6
    Your a lifesaver, thanks. It just clicked when I read what you said. for some odd reason i was storing the query string as 1 variable to keep some search config all in tack. but i could have just used get to load in the variables independently, just not bringing in the already set ID. now it works perfect. I would show you but its for a private tool.

    thanks and + rep.
     
    timallard, Mar 2, 2009 IP
  7. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #7
    $var = 1;
    $var = 2;
    echo $var; // output will be 2, not 1 + 2
    
    PHP:
    What I want to say is, if you use your variable again ( assign something to it ), it's automatically cleared not merged.
     
    ActiveFrost, Mar 3, 2009 IP
  8. mdrobiul

    mdrobiul Peon

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    hey, you just bring data and sending request over url. it's depending on you. if you ?id=1 is enough for the request why you're adding id=1&id=3 ??

    if you get the id using $_request[id] or $_GET[id], you'll get only one value. only 1 or 3. so destroy one in link.

    <a href="loading-curiosity.php?id=<?php echo '$row5['ID']' ?>">
    or
    <a href="loading-curiosity.php?<?php echo $queryString ?>">
     
    mdrobiul, Mar 3, 2009 IP