dynamically generated links to terms in a terminological db

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xinelo
Forum Newbie
Posts: 5
Joined: Thu Nov 20, 2003 8:57 pm

dynamically generated links to terms in a terminological db

Post by xinelo »

in the first place, thanks a lot for taking the sweat to read this ;)

i did search the tutorials and the internet but i´m afraid my question is too specific to be able to find a solution easily. and it might not be worth reading the whole manual, as i might eventually find out that what i´m trying to do cannot actually be done with php and the manual didn´t refer to it. well, i´ve started learning php not long ago and I use it for building glossaries on-line. and here it goes:

i think the best way to explain this is getting down to a concrete example, even if it gets longer to read. this is about interlinked dynamically generated webpages (if this is the right way to call them), in particular about a terminological dictionary on-line. if you go to http://dvtg.f2o.org and search for, say, "chinela", you should get to http://dvtg.f2o.org/paxina_do_termo.php?id_termo=270 where you have the definition of the term, as well as other (now irrelevant) information. the first word of the definition, called a descriptor, is usually a broader term, which also exists in the database the information is being retrieved from ("zoca" in this case: "chinela" is a type of "zoca"). so far so good

the thing is, it would be excellent to get a link on that broader term, so that to see the terminological information relating to it you'd just have to click on it. now, if you want to see the terminological informaition related to "zoca", you have to go back to the search tool and type "zoca" and searc. some sites, like e.g. Webopedia, use the traditional way of interlinking pages (see for example http://www.webopedia.com/TERM/M/machine_language.html), that is, writing in longhand the word within the <a> tag. I think it works similarly for XML. but this is, of course, not a feasible way to make links on words on a dynamically generated page, i.e. words which come from the database and actually do not exist on a html page. what I actually want to do is display a link of every word within the definition which is a term in the database, that is, which is assigned a record

the question is:

i´d like to know if there's a way to do this with php and if there is, you don´t need to explain in detail how it works, it would be perfect if you could just tell me the fonction or the relevant section in the documentation so i could narrow my search much more. just in case it is of any help i´m using mysql and apache

thanks a lot again for your help and patience
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

well, that is going to be a lot of fun coding for you hehe. cuz what you are gonna have to do is make a list of all the words you have definitions for (say in a text file), and then put a function in there that does a read word-by-word of the definition, and checks that list for valid definable words. then, when you find one, parse the definition, insert the link tag, and then reload it to the page.

a better way could be to do something like :

1) create the list to a text document.
2) then on the submit button
a) search the database for word and definition.
b) write this to a temporary file.
c) parse that file by using spaces as your delimiter ( since each word will undoubtebly be seperated by spaces) as well as the \n\r for eol.
d) assign each value inside that file to an array.
e) for each array, search the list of words in your text file that has all the words in your dictionary, and when you find one, assign those results to ANOTHER array.
3) Using the arrays you find, you can then do a for($i=0; $i<=$dict_words_found; $i++) and save each value as a link.
4) then, rewrite that value to the array in which you originally pulled it from ( the one that read the file ), and replace the words you found in that temporary file that matches your dictionary files with the new result, copy that entire file, and post it with htmls to the page.


LOL, maybe that seems too long, but at least you know it's possible. there are undoubtedly shortened ways to do this, but you are gonna have to do a lot of research (namely on fopen, file, array, and others ).

hope that helps.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

also, if u are lucky, someone will have written a search script that searches a text document for $key words that will seirously reduce the amount of code you have to write.

again, these are only my suggestions. another programmer with more theory and ideas may have a better solution for you.
Post Reply