One idea is to just take a more modular approach. Something like:
<?php
class DBCheck {
var $field_data = array();
var $where = 'WHERE (';
function prep($field, $data) {
$this->where .= "$field='$data' OR ";
}
function check_tbl($table) {
$where = substr($this->where, 0, -4).')';
$query = "SELECT * FROM $database_name.$table $where";
$rslt = mysql_query($query);
if($rslt){
return mysql_fetch_assoc($rslt);
}
else
return false;
}
}
Now, it's just a matter of doing:
$chck = new DBCheck;
$chck->prep_check('name', 'Jane');
$chck->prep_check('name', 'Blah');
$found = $chck->check_tbl();
Then it's a matter of differencing the found results (in an array) against an array of all possibilities. Then you use a class (like above) to create a set of INSERT statements to be executed at once, or like an SQL file would be.
Heck, you could create one class to do it all and just call the function as needed 😉 It's totally possible....