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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting an array from a link

    Hey guys
    I have a question that I hope you can help me with...

    I have a link that looks something like that

    www.mysite.com?id-1=123&id-2=456....id-(n)=i
    *could be 1 ID or 100 id's passed on with the link

    what I wanted to know is how can I put all of these id's into a sql query

    and get a specific info' for each of these id's

    I need it to be some kind of a loop or something...I dont know

    ex:
    for each id I want a DIV with some info

    <div>//id=1
    echo $row['address'];
    echo $row['phone'];
    </div>

    <div>//id=2
    echo $row['address'];
    echo $row['phone'];
    </div>
    .
    .
    <div>//id=i
    echo $row['address'];
    echo $row['phone'];
    </div>

    some king of a loop till he echoes the last ID# from the link

    any one ?

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    where does the link originate from? wouldn't those values already exist to combine to make the link?

    this is really a question for your front end application. if it is php for example we can move the thread to that particular forum. Let us know.

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello
    they were originated in a different page with javascript
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Setting cookie and passing to other page in url</title>
    
        <script language="javascript" type="text/javascript">
            var i = 0;
            var ids = new Array();
    
            function setCookie(c_name) {
                c_name += "-" + i++;
                ids[i] = c_name;
                var value = document.getElementById("i1").value;
                document.cookie = c_name + "=" + escape(value);
            }
    
            function getVarNPost() {
                var valuestoPost = "";
                for (x in ids) {
                    c_start = document.cookie.indexOf(ids[x] + "=");
                    if (c_start != -1) {
                        c_start = c_start + ids[x].length + 1;
                        c_end = document.cookie.indexOf(";", c_start);
                        if (c_end == -1) c_end = document.cookie.length
                        valuestoPost += ids[x] + "=" + unescape(document.cookie.substring(c_start, c_end)) + "&";
                    }
                }
                window.location = "http://www.classimoveisrn.com?" + valuestoPost;
    
            }
        </script>
    
    </head>
    <body>
        <form id="f1">
        <input type="text" id="i1" />
        <input type="button" id="submit" value="submit" onclick="setCookie('id')" />
        </form>
        <input type="submit" id="post" value="submit" onclick="getVarNPost()" />
    </body>
    </html>


  •  

    Posting Permissions

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