Exact Posted November 23, 2009 Share Posted November 23, 2009 Ok guys, i am only good with the basics, sorry if i come off stupid I want to write on this file if page is equal to home.php show middle.php, if it equals any other page do not show middle.php this is the body where i want to write it: <tr> <td><?php include("middle.php"); ?></td> </tr> <tr> <td><?php include("bottom.php"); ?></td> </tr> bottom.php is where the default page loads. so in lamens terms i want to say show middle.php on the home page and dont show it anywhere else ANY help would be soooo appreciated!! Quote Link to comment Share on other sites More sharing options...
Goldeneye Posted November 23, 2009 Share Posted November 23, 2009 This might be helpful <?php function page($name){ $uri = basename($_SERVER['REQUEST_URI']); if(strpos($uri, '?') !== false) $uri = reset(explode('?', $uri)); return $page == $uri ? true : false; } ?> And then to use it just do if(page('home.php')) include('middle.php'); Quote Link to comment Share on other sites More sharing options...
Exact Posted November 23, 2009 Author Share Posted November 23, 2009 hmmm... cant seem to get it working. its not giving any errors but its not showing middle.php when the home page or any other page is there. Quote Link to comment Share on other sites More sharing options...
emopoops Posted November 23, 2009 Share Posted November 23, 2009 this is much easier if($_SERVER[sCRIPT_NAME] == "/home.php){include (middle.php);} or if($_SERVER[sCRIPT_NAME] == "/anydirectory/home.php){include (middle.php);} if you were on yoursite.com/home.php echoing that server variable script name outputs: /home.php and if theres a string on the end.. like site.com/home.php?blah=blah3983&a=1 it will still output : /home.php Quote Link to comment Share on other sites More sharing options...
Exact Posted November 24, 2009 Author Share Posted November 24, 2009 this is the site i am working on: www.exactmining.com.au/new cant get this... either doesnt show either, or just shows home.php attached is the four files i am using. all that is in middle.php is an image, any help would be so great. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Goldeneye Posted November 24, 2009 Share Posted November 24, 2009 Sorry, the reason my function didn't work was because I unknowingly changed a variable-name in the middle of a function... Try this function, instead, I should work: <?php function page($name){ $uri = basename($_SERVER['REQUEST_URI']); if(strpos($uri, '?') !== false) $uri = reset(explode('?', $uri)); return $name == $uri ? true : false; } ?> Quote Link to comment Share on other sites More sharing options...
emopoops Posted December 5, 2009 Share Posted December 5, 2009 script name should show /home.php or /blah/home.php try echoing the variable. that ones script is too complicated Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.