zonkd Posted April 19, 2008 Share Posted April 19, 2008 I'm trying to use an IF ELSE to say that is the page is www.mysite.com/index.php then use these includes. But if the page is www.mysite.com/index.php?page=3 or ANY alternative to the straight forward naked index page, please DON'T include it. Does anyone know how to perform the trick, please? I've been trying with every variation I can think of, but I can't find the right combination for the function to work. Cheers Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/ Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 <?php // index.php if(trim($_SERVER["QUERY_STRING"]) == "") { include("/path/to/file.php"); } // rest of code ?> Tried that? Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521167 Share on other sites More sharing options...
zonkd Posted April 19, 2008 Author Share Posted April 19, 2008 No, I haven't, Chigley, and thanks very much for the suggestion. I'm struggling to see what will go where with it, though. Do I put the address that's wanted into the quotes? Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521175 Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 No, I haven't, Chigley, and thanks very much for the suggestion. I'm struggling to see what will go where with it, though. Do I put the address that's wanted into the quotes? You don't need to put anything in the quotes. Just stick it at the top of your current index.php Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521176 Share on other sites More sharing options...
zonkd Posted April 19, 2008 Author Share Posted April 19, 2008 Chigley! You're a star. I can't see how it works, but it works. I've spent hours this morning jiggling, and this is it. If I had a fortune, it would be yours. Many, many thanks. Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521181 Share on other sites More sharing options...
ohdang888 Posted April 19, 2008 Share Posted April 19, 2008 well you could have seperate places for each page... if(strlen($page) == 0){ do page one }elseif($page == 2){ do apge 2 } Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521286 Share on other sites More sharing options...
zonkd Posted April 19, 2008 Author Share Posted April 19, 2008 Thanks very much, ohdang888, that looks good and will be really useful. On this particular project, there's just the one need for it, and mainly because many files use the index page (you know, ?page=2, etc). Usually I can use get_id. But this code of yours look really handy. Much obliged. Cheers. Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521291 Share on other sites More sharing options...
ohdang888 Posted April 19, 2008 Share Posted April 19, 2008 i smuch of the pages are the same, you can just put this in your code: if(strlen($page) == 0){ include file }elseif($page == 2){ include this other file } Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521331 Share on other sites More sharing options...
zonkd Posted April 19, 2008 Author Share Posted April 19, 2008 Thanks very much. Link to comment https://forums.phpfreaks.com/topic/101839-if-its-this-page-do-else-dont/#findComment-521338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.