cosi funziona , però l'idea del chekbook invece del classico aggiungi ad ogni prodotto sarebbe carino...
//codice funzionante
Codice PHP:
<?php
// inserimento dati ordini
include('../config.php');
$codice_parrucchiere = $_POST['codice_parrucchiere'];
$codice_articolo = $_POST['codice_articolo'];
$data = date('d/m/Y');
$n_fattura = $_POST['n_fattura'];
// ciclo per inserire tanti prodotti in oridne
$sql = "INSERT INTO ordini (`codice_parrucchiere`,`codice_articolo`, `data`, `n_fattura`)VALUES ('$codice_parrucchiere','$codice_articolo', '$data', '$n_fattura')";
echo $sql;
@mysql_query($sql);
?>
<?php
$p_sql = "SELECT COUNT(n_fattura) FROM fattura WHERE codice_parrucchiere = '" . $_SESSION['codice_parrucchiere'] . "'";
$p_query = @mysql_query($p_sql);
$p_result=@mysql_fetch_array($p_query);
$n_fat=$p_result['COUNT(n_fattura)'];
$n_fact= $n_fat+1;
$z_sql = "SELECT * FROM carico_magazzino WHERE codice_parrucchiere = '1'";
$z_query = @mysql_query($z_sql);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Quantitá</td>
<td>Prodotto</td>
<td>Prezzo</td>
<td>Iva</td>
<td>Prezzo Ivato</td>
<td>Codice Prodotto</td>
</tr>
</table>
<?php
while($z_result = @mysql_fetch_array($z_query)){
?>
<form action="ric.php" method="post" enctype="application/x-www-form-urlencoded">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?=$z_result['quantita'];?></td>
<td><?=$z_result['descrizione'];?></td>
<td><?=$z_result['prezzo'];?>€</td>
<td><?=$z_result['aliquota_iva'];?>%</td>
<td><?=$z_result['prezzo_ivato'];?>€</td>
<td><input name="codice_articolo" type="hidden" value="<?=$z_result['codice_articolo'];?>" /><input name="codice_parrucchiere" type="hidden" value="1">
<input name="n_fattura" type="hidden" value="<?php echo $n_fact;?>" /><input type="submit" value="Inserisci" /> </td>
</tr>
</table></form><?php
}
?>
Codice PHP:
<?php
// inserimento dati ordini
foreach(ordini as $ordini) {
$codice_parrucchiere = $codice_parrucchiere->$_POST['codice_parrucchiere'];
$codice_articolo = $codice_articolo->$_POST['codice_articolo'];
$data = $data->date('d/m/Y');
$n_fattura = $n_fattura->$_POST['n_fattura'];
// ciclo per inserire tanti prodotti in oridne
$sql = "INSERT INTO ordini (`codice_parrucchiere`,`codice_articolo`, `data`, `n_fattura`)VALUES ('$codice_parrucchiere','$codice_articolo', '$data', '$n_fattura')";
echo $sql;
@mysql_query($sql);
}
?>
<?php
include('../config.php');
$p_sql = "SELECT COUNT(n_fattura) FROM fattura WHERE codice_parrucchiere = '" . $_SESSION['codice_parrucchiere'] . "'";
$p_query = @mysql_query($p_sql);
$p_result=@mysql_fetch_array($p_query);
$n_fat=$p_result['COUNT(n_fattura)'];
$n_fact= $n_fat+1;
$z_sql = "SELECT * FROM carico_magazzino WHERE codice_parrucchiere = '1'";
$z_query = @mysql_query($z_sql);
?>
<form action="ric.php" method="post" enctype="application/x-www-form-urlencoded">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Quantitá</td>
<td>Prodotto</td>
<td>Prezzo</td>
<td>Iva</td>
<td>Prezzo Ivato</td>
<td>Codice Prodotto</td>
</tr>
<?php
while($z_result = @mysql_fetch_array($z_query)){
?>
<tr>
<td><?=$z_result['quantita'];?></td>
<td><?=$z_result['descrizione'];?></td>
<td><?=$z_result['prezzo'];?>€</td>
<td><?=$z_result['aliquota_iva'];?>%</td>
<td><?=$z_result['prezzo_ivato'];?>€</td>
<td><input name="codice_articolo" type="checkbox" value="<?=$z_result['codice_articolo'];?>" /><input name="codice_parrucchiere" type="hidden" value="1">
<input name="n_fattura" type="hidden" value="<?php echo $n_fact;?>" /></td>
</tr><?php
}
?>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td><input type="submit" value="Inserisci" /> </td>
</tr>
</table></form>
L'ERRORE è
Warning: Invalid argument supplied for foreach() in /web/htdocs/www.werwolfe.it/home/parrucchieri/admin/ric.php on line 3
:berto: