
September 27th, 2002, 08:04 PM
|
|
Registered User
|
|
Join Date: Aug 2002
Posts: 28
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
comparing array of values to database
Hi
I need to be able to compare an array of values to a database tables before actually entering them in the db (to prevent duplicate entries).
I know how to compare specific values like this...
PHP Code:
$sql = "SELECT * FROM users WHERE user_name = '$user' and password = '$password'";
$result = mysql_query($sql);
$num = mysql_numrows($result);
if($num != '0')
{
echo 'Values entered';
}
but not an array. The code below is what I have, 'winners' is the array.
PHP Code:
if(is_array($winners))
{
for($i=0; $i < count($winners); $i++)
{
$add = addslashes($winners[$i]);
$result = mysql_query("INSERT INTO winners VALUES(NULL, $weekid,'$add', now())");
}
TeamsPicked();
}
else
{
echo Error();
}
Could someone point me in the right direction?
Thanks 
|