jmilane Posted September 25, 2006 Share Posted September 25, 2006 I want to send people a link that, when clicked, will open a php page which searches based on an id number. The id number will have to be appended to the end of the url.How do I set this up? Do I have to take the id number off of the url in the processing script and then incorporate it into a query?I know this probably has to do with the "?" in php URLs - but I am extremely new. Thank you. Link to comment https://forums.phpfreaks.com/topic/21983-how-do-i-pass-a-variable-via-url-and-then-have-it-brought-into-a-script/ Share on other sites More sharing options...
trq Posted September 25, 2006 Share Posted September 25, 2006 A simple example.[code=php:0]<?php if (isset($_GET['id'])) { echo "You clicked foo"; } else { echo "<a href='?id=foo'>foo</a>"; }?>[/code]This is all within one page but should give you the idea. Link to comment https://forums.phpfreaks.com/topic/21983-how-do-i-pass-a-variable-via-url-and-then-have-it-brought-into-a-script/#findComment-98185 Share on other sites More sharing options...
AndyB Posted September 25, 2006 Share Posted September 25, 2006 http://www.somewhere.com/go_here.php?id=8972As a very simple example:[code]<?php// go_here.phpif (isset($_GET['id'])) { $id = $_GET['id']; // retrieve id value passed by URL} else { exit();}... your code follows ...[/code] Link to comment https://forums.phpfreaks.com/topic/21983-how-do-i-pass-a-variable-via-url-and-then-have-it-brought-into-a-script/#findComment-98187 Share on other sites More sharing options...
jmilane Posted September 25, 2006 Author Share Posted September 25, 2006 [quote author=thorpe link=topic=109415.msg440924#msg440924 date=1159193906]A simple example.[code=php:0]<?php if (isset($_GET['id'])) { echo "You clicked foo"; } else { echo "<a href='?id=foo'>foo</a>"; }?>[/code]This is all within one page but should give you the idea.[/quote]So the $_GET var would be passed just in the url... like www.mysite.com/search?id=fooBut then the file itself would simply be named www.mysite.com/search.php?And then the $_GET var would be whatever immediately follows the ? (in this case 'id'?)Thanks! Even if I am wrong... Link to comment https://forums.phpfreaks.com/topic/21983-how-do-i-pass-a-variable-via-url-and-then-have-it-brought-into-a-script/#findComment-98193 Share on other sites More sharing options...
mendoz Posted September 25, 2006 Share Posted September 25, 2006 [quote author=jmilane link=topic=109415.msg440932#msg440932 date=1159194181][quote author=thorpe link=topic=109415.msg440924#msg440924 date=1159193906]A simple example.[code=php:0]<?php if (isset($_GET['id'])) { echo "You clicked foo"; } else { echo "<a href='?id=foo'>foo</a>"; }?>[/code]This is all within one page but should give you the idea.[/quote]So the $_GET var would be passed just in the url... like www.mysite.com/search?id=fooBut then the file itself would simply be named www.mysite.com/search.php?And then the $_GET var would be whatever immediately follows the ? (in this case 'id'?)Thanks! Even if I am wrong...[/quote]It will be named www.mysite.com/search.php, Link to comment https://forums.phpfreaks.com/topic/21983-how-do-i-pass-a-variable-via-url-and-then-have-it-brought-into-a-script/#findComment-98364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.