dannybrazil Posted March 11, 2010 Share Posted March 11, 2010 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 ? Link to comment https://forums.phpfreaks.com/topic/194963-getting-an-array-from-a-link/ Share on other sites More sharing options...
jl5501 Posted March 11, 2010 Share Posted March 11, 2010 $ids = array(); foreach($_GET as $key => $value) { if(substr($key,0,2) == 'id') { $ids[] = $value; } } That will give you all of the id's in an array that you can then use in your query Link to comment https://forums.phpfreaks.com/topic/194963-getting-an-array-from-a-link/#findComment-1024985 Share on other sites More sharing options...
dannybrazil Posted March 11, 2010 Author Share Posted March 11, 2010 I think you broke the record of "time to respond" Thanks well as I mentioned Im a newbie ... After your code here $ids = array(); foreach($_GET as $key => $value) { if(substr($key,0,2) == 'id') { $ids[] = $value; } } How should I SQL it exactly.... eventually I need to get something like that: <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> If you can help me it will be great Danny Link to comment https://forums.phpfreaks.com/topic/194963-getting-an-array-from-a-link/#findComment-1024987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.