Buonasera,
ho un form che contiene un input type di tipo checkbox come nel codice sotto:
<?php
$query=mysql_query("SELECT * FROM brands") or die(mysql_error());
while ($rows=mysql_fetch_array($query))
{
extract($rows);
?>
<tr>
<td class="admin_select_text" >
<?php echo $brand;?>
</td>
<td class="admin_select_input" >
<input type="checkbox" name="<?php echo $brand;?>"
value="<?php echo $brand;?>">
</td>
</tr>
<?php
}
?>
dal form passo a una pagina di check del risultato che deve vedere se è stato selezionato il brand
echo "Inizio controllo per selezione brand
";
//Controllo se è stato selezionato un brand
$query = mysql_query("SELECT * FROM brands") or die( mysql_error());
if( mysql_num_rows($query) != 0)
{
//Se entro qui significa che ci sono brand già inseriti
//l'utente deve selezionato almeno un brand per continuare //l'inserimento
while ( $rows = mysql_fetch_array($query) )
{
extract($rows);
-----------------------------------------------qui inizia il problema prima ho verificato tutte le variabili e sono tutte a posto ma qui..........................................
if ( isset($_POST[$brand]) )
{
echo "Ho trovato un brand ".$_POST[$brand]."
";
$check_brand=1;
$id_brand_array[]= $id_brand;
$brand_array[] = $_POST[$brand];
}
}
}
il problema che nell'ultima if mi ci entra solo se dal forma è stato selezionato un campo che non contiene spazi, per esempio se l'utente seleziona "pippo" funziona tutto ma se seleziona "pippo 2" non entra nell'if.
Grazie per ogni aiuto.
Leo

Rispondi quotando