Hi all
I have a little problem with this script ... When I press (search) button it shows all words that contains the first letter . for example when I search about the word ( apple ) it shows all words stored in the database which start with the letter (a) .
What I want here is to show the word ( apple ) not all words
that contain or starts with the letter (a) . In case of the result or the requested word not found How could I say ?? for example
" Sorry this word doesn't exist"
What should I add or change and how ??????
thank you in advance .
<html dir="rtl">
<head>
<title><?print $word;?></title>
</head>
<body>
<form action="trans.php" method="GET">
<center>
<div style="border:1px solid;background-color:#EEEEEE;width:50%">
<input type="text" name="word"><br>
<input type="submit" value="Search">
</div>
</center>
</form>
<hr>
<?
$link = mysql_connect("localhost","","");
$db = mysql_select_db("test");
if($GET[word]){
$word = addslashes($GET[word]);
if(preg_match("/[a-zA-Z]/",$word)){
$lang = "en";
print "<div style=\"background-color:#efefef\"><hr>";
}
else{
$lang = "fr";
print "<div style=\"background-color:#efefef\"><hr>";
}
$sql = ("SELECT * FROM trans WHERE en RLIKE '$word' OR fr RLIKE '$word' ");
$query = mysql_query($sql);
while($found = mysql_fetch_frray($query))
($lang=="en")? print $found[en]." : <b>".$found[fr]."</b><hr>\n" : print $found[fr]." : <b>".$found[en]."</b><hr>\n";
}
?>