[thelist] Online Glossary Database (PHP/MySQL))

Jeniffer C. Johnson lead at offlead.com
Sat Jan 25 12:03:02 CST 2003

At 05:49 AM 1/25/2003, Gijs van Tulder wrote:

>If you don't want to do it yourself, you'll need a script that does this for
>you. This script will have to look up each word in the definition in the
>database. You could do something like this:
>$word = 'things';
>// get definition from database
>$result = mysql_query("SELECT definition FROM words WHERE word='$word'");
>$definition = mysql_result($result, 0, 'definition');
>// split definition in words
>$words = explode(' ', $definition);
>// look up each word
>for ($i=0, $i<count($words); $i++) {
>         $result = mysql_query("SELECT word FROM words WHERE word='".
>                               $words[$i]."'");
>         if (mysql_num_rows($result)==1) {
>                 // this word has a definition
>                 // make a link
>                 $words[$i] = '<a href="glossary.php?word='.$words[$i].'">'.
>                              $words[$i].'</a>';
>         }
>// join the words and tags
>$linked_definition = join(' ',$words[$i]);
>// display results
>echo "Word: $word<br>\nDefinition:<br>\n$linked_definition";
>This obviously isn't very efficient. For each pageview, the script has to
>link the definition. You might want to run the script once, and then save
>the linked definitions in the database. The glossary script then just has to
>display the definition.

Yeah, not quite what I'm hoping I can do, somehow. I don't want to have to
figure out which terms that are in the glossary are also used in
definitions of other glossary terms. And the glossary will be worked on
fairly constantly for a couple of years at least. I'm hoping there's some
way to make the php and the mysql do all of this work--matching up of
defined terms to strings of words used in other definitions.


More information about the thelist mailing list