Hi,
I would need to receive a list of text from the user and compare each entry in the list with the entries in the mySQL database. However, my code doesn’t seem to run properly:
[code=php]
<?
include(‘common.php’);
$fp = $_POST[‘input’];
$conn=mysql_connect($_cfg[‘host’],$_cfg[‘user’],$_cfg[‘pass’]);
mysql_select_db($_cfg[‘db’],$conn);
$fp = str_replace(“n”, ” “, $fp);
$data = explode(” “, $fp);
$foundlist = “”;
$notfoundlist = “”;
$c = 0;
while ($c < count($data)) {
$res=mysql_query(‘SELECT * FROM `list` WHERE `word`=”‘.$data[$c].'”‘,$conn) or die(mysql_error());
if (mysql_num_rows($res)<1)
{
$notfoundlist = $notfoundlist . “n” . $data[$c];
}
else
{
$foundlist = $foundlist . “n” . $data[$c];
}
$c++;
}
?>
Only the last entry in the list will be processed properly. Can someone help?
Thanks.
Daniel