Compare two arrays in mysql

From: Date: Thu, 21 Dec 2000 10:40:55 +0000
Subject: Compare two arrays in mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31395@lists.php.net to get a copy of this message
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

« previous php.general (#31395) next »