# PHP - get the characters before the dot

**URL:** <https://forum.kirupa.com/t/php-get-the-characters-before-the-dot/107335>\
**Category:** Uncategorized\
**Created:** [April 14, 2004, 2:23pm UTC](https://forum.kirupa.com/t/php-get-the-characters-before-the-dot/107335 "2004-04-14T14:23:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [April 14, 2004, 2:23pm UTC](https://forum.kirupa.com/t/php-get-the-characters-before-the-dot/107335/1 "2004-04-14T14:23:57Z")

</div>

I have two files:

1.php - displays data  
data.inc - gets the heading and the body of the HTML page from MySql database and prints it

1.php contains this line:  
include(“data.inc”);

I also have 2.php, 3.php, 4.php, 5.php.  
data.inc has this lines:

$sql = “SELECT heading, subHeading, body FROM superintendent WHERE id = 1”;

as you can see. the query says WHERE ID = 1; but i want the query to retrieve the id number dynamically. instead of WHERE ID = 1, i would like to have a variable like WHERE ID = $id.

so, thats why i need a function, which i have been looking for but cant find it, to retrieve the filename like 4.php (maybe using PHP\_SELF) and then get the characters BEFORE the dot, so i would have a ‘4’ in the variable, and the result of the query be WHERE ID = 4;.

if there is a better way to do this, please let me know.
