ramiwahdan Posted March 30, 2020 Share Posted March 30, 2020 (edited) Hi, I have an empty array and i populated the array through code and i printed to check if everything ok. So far so good. I now have an array say $ids = ('123','456'). Now, i have a table in db that has ids as well, I need to make a query to check for id's that are not inside the array, so if the db table have '123','456','789' i want the result of the query to be only the last one '789'. $arr = array(); array_push($arr,$previd2); print_r ($arr); I get the result as follows: Array ( [0] => 533349 [1] => 533355 ) so what query i can use to get the other id's from db table that is not part of that array? here is what i tried: $qry = "select staffname, joindate from staff WHERE OracleID NOT IN ($arr)"; $answ = mysqli_query($con, $qry); I get error: Notice : Array to string conversion in C:\xampp\htdocs\AttendanceSystem\login\reportsforallid.php Edited March 30, 2020 by ramiwahdan more info Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted March 30, 2020 Author Share Posted March 30, 2020 Figured it out $ids = join("','",$arr); $qry = "select OracleID, StaffName,joindate from staff WHERE OracleID NOT IN ('$ids')"; $answ = mysqli_query($con, $qry); Thanks Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 30, 2020 Share Posted March 30, 2020 I"m guessing you did a little research to look up that function. Also called "implode". But you probably found that out too. Good work! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.