Hi all, Not sure if this is possible with just HTML, but I assume it isn't that difficult. If I sent people to a link like this: www.mydomain.com/?searchterm Is there anyway I could insert "searchterm" in my page easily? That way I could make a page header or something say buy "searchterm" here or whatever. Obviously the page would need to update for each visitor automatically based on the URL (the part after the ?) he arrived using. Can anyone point me in the right direction? Thanks.
Not in HTML, but if you make it a php page, just throw this in where ever you want searchterm to print. <?php foreach($_GET as $key => $value){ echo $key; } ?> PHP: There's probably an easier way, but that works fine for me at least. JavaScript can probably do it as well.
Your domain would have to be something like yourdomain.com/index.php?search=whatever if you're using PHP.
+ rep added - that works like a charm - thanks! One more quick thing, when I use /?search%20term the result on the page is search_term Any way to make a space show up instead of the line?
<?php foreach($_GET as $key => $value){ $key = str_replace('_',' ',$key); echo $key; } ?> PHP: There's probably a nicer way to do it though. I thought urldecode would do it, but I just tried it and it doesn't work well with $_GET.
I suggest using + instead of %20, looks nicer <?php foreach($_GET as $key => $value){ echo str_replace("+"," ",$key); } ?> Code (markup):