Could someone please take a look and let me know what i’m doing wrong…
What i’m trying to acheive is, in the Database i have:
AGENT_REF = 1
AGENT_REF = 2
AGENT_REF = 3
AGENT_REF = 4
AGENT_REF = 5
In a file uploaded that parses information
$blmarArray = array($agentref);
AGENT_REF = 1
AGENT_REF = 2
AGENT_REF = 3
AGENT_REF = 5
What i’d like to happen is to extract the AGENT_REF from the database that ISN’T in the file uploaded, in this case AGENT_REF = 4 so i can DELETE it from mysql.
$sql_archeck = mysql_query("SELECT `AGENT_REF` FROM `eprentals`");
$archeck = mysql_fetch_array($sql_archeck);
$sqlarArray = array($archeck);
$combyArrayDiff = array_diff($blmarArray, $sqlarArray);
print_r ($combyArrayDiff);
All i’m getting is the last or first AGENT REF from the database and not the ones that arn’t present in the db.
(In the db there is 11 but the file uploaded only 8 are present, so i’d like to delete (SHOW) the ones that are in the DB that have been removed from the file uploaded)
Hope you can offer me some guidance into where i’m wrong with this and I Thank you for your time and appriciate your help!
from php manual:
so insted of
array_diff($blmarArray, $sqlarArray)you should usearray_diff($sqlarArray, $blmarArray)= the big array as first parameter, and the samller array as 2nd parameter
you also need to fetch all rows from the database, not just the first