Hey all, happy EASTER, and yes im doing work over it lol. I need a php page (Just one page calling back to itself) to have this hierachal system which has two links, one to go up one level, one to go down. If I was on the section:- html/fieldset/legend (with its description of legend below) then I can go up, using one link too:- html/fieldset/ or down using the other link (possible more than 1, if you go down):- html/fieldset/legend/a html/fieldset/legend/b Please could you help as Ive tried to do this but finding it hard. The file getting the html/fieldset/etc from, is just a textfile with terms and explainations in. Each explaination has this tag #------ in front of it. Trip
Anyone help?? Adding to this description:- Ok, the textfile contains something like:- #------php A programming language #------php/array() Creates an array #------php/crypt() One-way string encryption (hashing) #------php/array()/combine() Creates an array by using one array for keys and another for its values #------html Another description #------html/form Another description #------html/form/buttons Another description When the person first goes to the php page it starts off displaying nothing, but has several links that they can click. In this case two html and php If the user clicks on the 'hyperlink' php It will display below #------php A programming language (gathering those two lines from the textfile and putting them some sort of box displaying on the php page) and will have two link options #------php/array() and #------php/crypt() If they click on array then it will display #------php/array() Creates an array and another possible link down #------php/array()/combine() but also with a link back up the hirarchy #------php So the php page will have links for this hirarchy and the #------blah Another description below I hope you understand :s
<?php $url=$_SERVER['REQUEST_URI']; if (substr($url,-1)=="/") {$url=substr($path,0,-1);} if (substr($url,0,1)=="/") {$url=substr($path,1);} $parts=explode('/',$url); $backlink =''; foreach ($i=0;$i<count($parts); $i++) {$backlink.=$parts[$i].'/';} echo '<a href="'.$backlink.'">some text</a><br />'; print_r($parts); ?> Code (markup): Is this pointing you in the right direction?
hey yeah, Ive progressed a bit. I can actually display the links with there explainations... and the possible links one level down at a time like it should do. But Im a bit stuck at the moment and I need to actaully show the content of a particular hyperlink after I click on them. (With the possible links down still showing(without there content)). Also Im stuck on showing links back up the levels. I think soimewhere in my current code which should do that. <?php $file_contents = file_get_contents("terms.txt"); $file_entries = explode('#------',$file_contents); $tree_point = ''; if (isset($_GET['tree_point'])) { $tree_point = urldecode($_GET['tree_point']); $tree_level = substr_count($tree_point,'/')+1; //Shows one forward slash term intially } foreach ($file_entries as $an_entry) { $an_entry = trim($an_entry); if (strlen($an_entry) > 0) { list($navigation,$description) = preg_split('/[\r\n]+/',$an_entry,2); $navigation = trim($navigation); $description = trim($description); $level = substr_count($navigation,'/'); if ($tree_level == $level && substr($navigation,0,strlen($tree_point)) == $tree_point) { echo '<a href="?tree_point='.urlencode($navigation).'">'.$navigation.'</a><div style="margin-top:5px;margin-bottom:2em;border:1px black solid;">'.$description.'</div>'; } } } ?> Code (markup):
anyone?? bump Ive tried to modfy it but all I get is either hyperlink duplicates or several levels down at a time.
Hola Trip, I can honestly say 2 things #1 I have no idea what you need #2 I feel bad because usually these things get solved in no time on DP and I guess the others are confused about what you need also. This poor guy has been trying to get this answered since Easter! If the above is still the problem I would probably suggest that you use explode the urls at the "/" then implode them (with 1 less) to build the links. Probably better advice would be for you to set up a db (or flat text db) that associates the folders with their father (eg. next folder up the chain) then you can just query for the father_id and you get all the children or search for the id using this father_id to get the parents. Clear as mud? Sorry I could not give you specific code but I feel like I'm still in Trig class and I really don't understand the question.
That's as close as what I could get to suggesting The I got pm's and emails expecting me to sort it all out go read a book or something - that's what I say. The same thing must have been done before in a much easier way......
Yeah ive got books, but sometimes find it hard to see which section will provide me will helpul suggestions. Im sure people have done it in easier ways but I have not seen it, so im doing it ;;--) Ok ill take your advice and tell you how i get on. edit: when i add it, all I get is a parse error, not quite sure Not sure what you mean by exploding the urls? You mean the file?