Sto provando in questo modo ma senza risultato..
Codice PHP:
$cg = $_POST['cg']; //id della news
if ($rel <> ""):
$query = "SELECT * FROM relation WHERE idn='$cg' AND idb='$brandrel'";
$res = mysql_query($query);
foreach($rel as $brandrel){
while ($row = mysql_fetch_array($res)) :
echo $row[idb];
if ($brandrel == $row[idb]) {
$upd1=mysql_query("UPDATE relation SET idb = \"$brandrel\" WHERE idn = \"$cg\"");
}
else {
$ins1=mysql_query("INSERT INTO relation(idn, idb) VALUES('$cg', '$brandrel')");
}
endwhile;
}
endif;