This topic is locked
[SOLVED]

How to get name of current page

5/13/2024 10:21:32 AM
PHPRunner General questions
P
PK author

Hello,
I have a custom delete button which I intend to place on several pages instead of creating a different one for each page. My idea is to get the page name when the button is clicked so I that I know which page to delete from and what other action I need to take.

So my question is how to get the current page name to appear as for example:

$currPage=getCurrentPageLink(myCurrentPage);

Thank you

Admin 5/13/2024

Please read this for instance:
https://stackoverflow.com/questions/5884807/get-url-parameter-in-php

Phrase to search in Google: "php read parameter from url"

C
Chris Whitehead 5/13/2024

I usually use $_SERVER[''REQUEST_URI'] , you might have to use this basename( $_SERVER[''REQUEST_URI'] ) to strip out the path.

There's also pathinfo($_SERVER['REQUEST_URI'])

If you want the parameters as well, they should be in the $_REQUEST variable

Have a test with them and see which suits your needs.

P
PK author 5/14/2024

Thank you admin and Chris.
Problem solved. I got the URL and managed to extract the table or view name out of it which actually what I wanted but I wish there was a way to just grab the table or view name directly, for the future it will save time and the need to create several buttons that essentially do the same thing in different tables.
Thanks again