I am new to PHP. I have done the following and it works, but I just think there has to be a better way of doing this and what I have done is very dirty hack.
So, I have a dictionary, with each word having a reference corresponding another word in another table. I want the Ar word searched for to search through the AR table to see if there is a match. If so, then return the Reference of that word, then go to the EN table and search if that reference exists there. Then return all the words with that reference number. The following does the job, but I was wondering if there is a better way of doing it.
<?php
if (!empty($_POST)){
$word = $_POST["word"];
$result = mysql_query("SELECT ref FROM en_a_ar WHERE ar = '$word'");
while($row = mysql_fetch_array($result)) {
$searchRef = $row['ref'];
$searchResult = mysql_query("SELECT en FROM en_a WHERE ref = '$searchRef'");
while($row = mysql_fetch_array($searchResult)) {
echo $row['en'];
echo "<br>";
}
}
}
?>