...

View Full Version : Getting an array from a link



dannybrazil
03-12-2010, 12:18 AM
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 ?

guelphdad
03-12-2010, 05:47 AM
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.

dannybrazil
03-12-2010, 10:45 AM
Hello
they were originated in a different page with javascript

<!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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum