[PHP] Compare two arrays in mysql From: Admin (psofthqma <email protected>)
Date: 12/21/00

hi all,

i have two arrays. The first one resulting from a selection of a form and the second one resulting from a row in mysql.
Now, how can i compare these two arrays and if there are no doubles insert them into mysql?

//The first array. This is where it sucks as it doesnt compare this array with the second one.
mysql_connect("$DBHost","$DBUser","$DBPass");
mysql_select_db ("$DBName");
$result = mysql_query ("SELECT THISDATA FROM THISDATA
                         WHERE THISDATA = '$THISDATA");
($row = mysql_fetch_array($result));
if ($result == $THISDATA
{
    print ("<b>Error:</b> THISDATA ALREADY EXISTS IN OUR DATABASE<b>");
    print ("$THISDATA");
    print ("</b> Go back and enter a new THISDATA.");
    print ("<p>");
    $verify = "bad";
}
else
{

//This is the second array (resulting from a user selection)which will be inserted into mysql ONLY if the data from this arrays doesnt already exist in another table. Which means that i have to fetch just one row of a table and compare it with the one from the user.
mysql_connect("$DBHost","$DBUser","$DBPass");
mysql("$DBName","INSERT INTO shoppers VALUES ('$UID','$date','tempID')");
for($count = 0; $count < sizeof($MYARRAY); $count++)
{
mysql("$DBName","INSERT INTO basket VALUES
('$UID','$MYARRAY[$count]','2','$date','$BasketItem')");
Header("Location: viewBasket.php?UID=$UID");
}
}

//Thanks in advance

_________________________________________________________
Do You Yahoo!?
Get your free  <email protected> address at http://mail.yahoo.com