Forum Moderators: coopster

Message Too Old, No Replies

Problem with making dynamic site design

         

m_leefs

5:47 pm on Feb 8, 2004 (gmt 0)

10+ Year Member



I'm trying to make a large science glossary with links to seperate pages that pulls information off a MySql database. I didn't want seperate pages for each definition, so I wanted to make dynamic pages. So far it works but I have problems when the word I want to link from have tough characters like "(" or "/" such as in "(A+T)/(G+C) ratio" Is there a way to keep such characters from being mis-recognized in the following PHP code?

Example:

$result = mysql_query(
"select wordID, word from glos");
while ($i = mysql_fetch_array($result)){
print <<<END
<a href="/definitions.php?word={$i['word']}">{$i['word']}</a><br>\n
END;
}

definitions.php:

$word = $_GET["word"];
$result = mysql_query(
"SELECT * FROM glos
where word = '$word'"
);
while ($i = mysql_fetch_array($result)){
$def = $i["def"];
print "Definition of $word : <br><br>\n";
print "$def<br>\n";
}

Thanks.

ergophobe

7:12 pm on Feb 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can work around it with addslashes, url encoding and so forth, but for all your trouble, you're going to end up with an obscure url with % signs and what not. I think you might want two cols, one for the "display name" and one for the "uri name" as in

www.domain.edu/AplusBoverDplusE/

If you're willing to give up "human readable" URIs, you can just use the id and have URIs like
www.domain.edu/definition.php?id=342

Tom