Salve sarà strano, ma non risco a capire, cioè ho uno script dove esegue perfettamente tutto quello che deve fare, però dopo l'esecuzione devo rieseguirlo nuovamente ma con valori differenti, cioè al posto di $_POST['Variante1'] va $_POST['Variante2'] però nella seconda esecuzione me lo esegue solo per un valore e poi passa ad un'altro script, come mai? Cosa potrebbe essere a far interrompere lo script?
Questo è il codice:
Codice PHP:
$id_tipo = array();
$q = "SELECT * FROM products_options WHERE products_options_name = '".$_POST['TipoVariante1']."'";
$s = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_array($s)){
$id_tipo[] = $row['products_options_id'];
}
$q = "SELECT * FROM products_options_values WHERE products_options_values_name = '".$_POST['Variante1']."'";
$s = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_array($s)){
$id_var = $row['products_options_values_id']; }
$q = "SELECT * FROM products_options_values_to_products_options WHERE products_options_id = '$id_tipo'";
$s = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_array($s)){
$id_p[] = $row['products_options_id'];
}
$array = explode("," ,$_POST['Variante1']);
$var1 = count($array);
$res1 = false; for($i=0;$i<$var1;$i++)
{
($id_tipo[$i]==$id_p[$i])
{
$res1=true;
}
}
if($res1 == false) {
$q = "SELECT * FROM products_options WHERE products_options_name = '".$_POST['TipoVariante1']."'";
$s = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_array($s)){
$id_tipo = $row['products_options_id'];
}
$q = "SELECT * FROM products_options_values WHERE products_options_values_name = '".$_POST['Variante1']."'";
$s = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_array($s)){
$id_var = $row['products_options_values_id'];
}
$q = "SELECT * FROM products_options_values_to_products_options WHERE products_options_id = '$id_tipo' AND products_options_values_id = '$id_var'";
$s = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_array($s)){
$tipo= $row['products_options_id'];
$opzione = $row['products_options_values_id'];
}
if (is_null($tipo)){
$query = "INSERT INTO products_options_values_to_products_options (products_options_id, products_options_values_id) VALUES ('$id_tipo', '$id_var')"; $insert = mysql_query($query); if(!$insert) die(mysql_error());
}
}
Grazie