I am using foreach loop for insertion query. At the same time I am matching value if those are exist in database or not. If value exist than I want to skip that particular key and than move to next key value to insert. Again it check if value exist or not than save record if values are not exist in database.
I have used following approach to do this.
foreach( $inputs as $key => $value) {
if ($key == 'empty') continue;
$check=mysql_query("select * from from t_atc_list where s_title='$key' and r_name='$value'");
if(mysql_num_rows($check)!=0){ continue; }
$result = mysql_query("INSERT into t_atc_list(a_name, s_title, r_name) values('$album','$key', '$value')")or die(mysql_error());
echo "<strong>$key</strong> Singer <strong>$value</strong></br>";
}
NOTE : (1). Values are inserting if value are already present that is duplicate entries. (2). I am getting warning " mysql_num_rows(): supplied argument is not a valid MySQL result resource in..."