Extract variables from a URL with PHP

Sorry to be a pain but I am trying to customise the js above to create a link e.g. if the url is as above website_url/generatebuynowbtn.php#id=65&num=1 how can I create a link on the same page such as this: <a href=“website_url/calcImage.php?id=65&num=1”>Buy Now</a> thus giving me the approriate variables to query my database and give me the product_id

Thanks again for all the help here lads …

Sorted! :slight_smile:

<script type=“text/javascript”>
curr_hash = location.hash;
new_hash = curr_hash.replace(“#”, “?”);
document.write(‘<a href="http://localhost:8888/site_name/calcImage.php’ + new_hash +‘">’);
document.write(‘Buy Now’);
document.write(‘</a>’);
</script>

Just being picky here.

Why are you using capital HTML?

nope

I was asking why you use it, not if.

document.write(‘<A HREF="http://localhost:8888/bodynudes/calcImage.php’ + new_hash +‘">’);
document.write(‘Buy Now’);
document.write(‘</A>’);

Just seems very old-fasioned really.

No I am not using it … I have edited my original post

Hi

The code I’m using for this function doesn’t seem to update when flash changes the url, more than likely because the page isn’t being refreshed but is there anyway I could ensure I always get the url params as without these I cannot “add to cart”

This was what I was using, based on your code but the link is only populated with the inital flash permalink structure e.g. buynow?id=1&num=1 but when the url changes the link remains the same

<script type=“text/javascript”>
curr_hash = location.hash;
new_hash = curr_hash.replace(“#”, “?”);
document.write(‘<a href="calcImage.php’ + new_hash +‘">’);
document.write(‘Buy Now’);
document.write(‘</a>’);
</script>

Any help would be appreciated …

Adam