Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML link to itself with GET

Tags:

html

php

get

I want to create a number of links within a page that have different GET parameters. However, I want the page that is called to be the current page.

<a href="ITSELF?param1=123&param2=345">Link1</a>
<a href="ITSELF?param1=234&param2=345">Link2</a>

Where "ITSELF" is the page currently loaded. I'd rather not include a hard link to a specific page location as this PHP can potentially be loaded from different URLs.

Suggestions?

-Jonathan

like image 766
Jonathan Avatar asked Dec 04 '22 08:12

Jonathan


1 Answers

Just don't put the ITSELF in there and it will do what you want, e.g.

<a href="?param1=123&param2=345">Link1</a>

Note that this will only include the path, not the query params, so if your current script is at /foo/bar?a=b, the link referred to will be /foo/bar?param1=123&param2=345. If you want to include the a=b as well, you'll need to figure it out server side.

like image 171
El Yobo Avatar answered Dec 29 '22 00:12

El Yobo