swamp Posted August 14, 2008 Share Posted August 14, 2008 Hey, I'm querying my mysql database with this: SELECT id, poster, subject, post, post_date, pagename FROM blog WHERE pagename='FILE NAME HERE'" where it says FILE NAME HERE I want it to detect the page name its currently on (eg my-page-01.php) and then call the row on the database depending on what page its on. Any help much appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/119626-getting-file-name/ Share on other sites More sharing options...
tibberous Posted August 14, 2008 Share Posted August 14, 2008 Do a print_r($_SERVER), one of the elements has something like the page name. I dunno, I'm really tired, do it and you'll see what I mean. It is useful as hell. Link to comment https://forums.phpfreaks.com/topic/119626-getting-file-name/#findComment-616308 Share on other sites More sharing options...
ignace Posted August 14, 2008 Share Posted August 14, 2008 SELECT id, poster, subject, post, post_date, pagename FROM blog WHERE pagename='" . basename(__FILE__) . "'" or SELECT id, poster, subject, post, post_date, pagename FROM blog WHERE pagename='" . basename($_SERVER['SCRIPT_NAME']) . "'" Link to comment https://forums.phpfreaks.com/topic/119626-getting-file-name/#findComment-616309 Share on other sites More sharing options...
swamp Posted August 14, 2008 Author Share Posted August 14, 2008 Wicked, that worked - thanks alot. Now how to i remove the file extension so instead of being my-file.php it just says my-file Cheers! Link to comment https://forums.phpfreaks.com/topic/119626-getting-file-name/#findComment-616319 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.