Hello-I have a form which has 50 fields and sends data to my code below as variables $ques1m, $ques1l, $ques2m, $ques2l, etc.
I also have a table called 'words' set up with 200 fields in 3 columns: words|mostsym|leastsym. The 'keywords' column contains 200 words some of which the data from the 50 form fields will match, each 'keyword' with a corresponding 'mostsym' and 'leastsym'.
What I'm trying to do is: if $ques1m matches a word in the 'keywords' column, return the corresponding 'mostsym'. If $ques1l matches a word in the 'keywords' column return the corresponding 'leastsym'. For instance: in the table 'words', the first record is keyword =red, mostsym=A, leastsym=B. If $ques1m = red (from the form), return "A". If $ques2l='red' return "B".
I don't know if my problem is my code or my table setup. I can't seem to figure out how to get them to relate. My code below just returns the same 'mostsym' and 'leastsym' for every instance. Any help would be greatly appreciated.
<?php
include ('connect.php');
$query = mysql_query("select * from words");
$result = $query;
$row = mysql_fetch_array($result);
if(" ". $row["keyword"] . "='$ques1m' ")
{
echo ("$ques1m " . $row["mostsym"] . "<br> ");
}
if(" ". $row["keyword"] . "='$ques2m' ")
{
echo ("$ques2m " . $row["mostsym"] . " <br>");
}
if(" ". $row["keyword"] . "='$ques3m' ")
{
echo ("$ques3m " . $row["mostsym"] . " <br>");
}
if(" ". $row["keyword"] . "='$ques4m' ")
{
echo ("$ques4m " . $row["mostsym"] . " <br>");
}
if(" ". $row["keyword"] . "='$ques5m' ")
{
echo ("$ques5m " . $row["mostsym"] . " <br>");
}
if(" ". $row["keyword"] . "='$ques1l' ")
{
echo ("$ques1l " . $row["leastsym"] . "<br> ");
}
if(" ". $row["keyword"] . "='$ques2l' ")
{
echo ("$ques2l " . $row["leastsym"] . "<br> ");
}
if(" ". $row["keyword"] . "='$ques3l' ")
{
echo ("$ques3l " . $row["leastsym"] . "<br> ");
}
if(" ". $row["keyword"] . "='$ques4l' ")
{
echo ("$ques4l " . $row["leastsym"] . "<br> ");
}
if(" ". $row["keyword"] . "='$ques5l' ")
{
echo ("$ques5l " . $row["leastsym"] . "<br> ");
}
?>