ilh Posted March 1, 2006 Share Posted March 1, 2006 I've started a little project in PHP and f00king hell its getting complicated now (for me lol). TBH i have done some stuff which i had thought was going to be too complicated and now i've got stuckon something which i think should be easy to resolve but i can't figure it out!First i'll mumble a bit about what i've done but there is a question at thebottom for any clever ppl :)So far i have created a template. I then create the page by calling thetemplate and supplying it a small amount of details (i.e. a query). It thenfigures out how many columns there are in the table, names them and then drawsthe table and fills in all of the data from the table. Each column name can beclicked on to arrange the data by that particular column (both ascending anddescending) and each record can be clicked on to load a different page with lotsof other info on it. This has taken me about a week of pure struggling. But since it is a templateit takes me about 2 mins to now create a page - i just copy the page, rename itand change the query and its all done Now the problem i'm having is with a function i kind of erm found :P Here it is: public function IsURLCurrentPage($url) { if(strpos($_SERVER['PHP_SELF'], $url )==false) { return false; } else { return true; } }Basically you pass it an URL and it looks up the URL in the address bar andtells you whether the address you gave it is the current page. This is all well an good until you use the URL to pass data to the script (ihave used it to pass the column name and direction in order to be able toarrange the data by any column). As soon as there is this extra data it thensays they don't match and it doesn't display the page quite as it should. For example the URL might look like /findpc.php?col=Name&dir=asc and i onlywant it to check it against the findpc.php bit of the address So all i need to do is tell it to ignore everything after (and including) the ?when comparing the addresses. But how? I'm sure i should be able to figure it out myself but I think my brain hasoverloaded. I'm always wary about thinking too much cos i might not have enoughthought power left for emergencies :P Quote Link to comment Share on other sites More sharing options...
zq29 Posted March 1, 2006 Share Posted March 1, 2006 This should do the trick:[code]public function IsURLCurrentPage($url) { $pos = strpos($url,"?"); if($pos !== FALSE) $url = substr($url,0,$pos); if(strpos($_SERVER['PHP_SELF'],$url) === FALSE) { return FALSE; } else { return TRUE; }}[/code] Quote Link to comment Share on other sites More sharing options...
ilh Posted March 2, 2006 Author Share Posted March 2, 2006 taverymuchly! :) 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.