Quote Originariamente inviata da badaze Visualizza il messaggio
Prova questo.

File : test319.php
Codice PHP:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><?php 
if (isset($_POST['bottone'])) {
 if (
$_POST['bottone'] == "Invia") {
 
 foreach(
$_POST['prodotto'] as $key => $value) {
  print 
"prodotto chiave=$key valore=$value<br/>";
 } 
// foreach($_POST['prodotto'] as $key => $value)
 
print "<hr/>";
 foreach(
$_POST['fornitore'] as $key => $value) {
  print 
"fornitore chiave=$key valore=$value<br/>";
 } 
// foreach($_POST['fornitore'] as $key => $value)
 
print "<hr/>";
 foreach(
$_POST['descrizione'] as $key => $value) {
  print 
"descrizione chiave=$key valore=$value<br/>";
 } 
// foreach($_POST['descrizione'] as $key => $value)
 
print "<hr/>";
 foreach(
$_POST['quantita'] as $key => $value) {
  print 
"quantita chiave=$key valore=$value<br/>";
 } 
// foreach($_POST['quantita'] as $key => $value)
 
print "<hr/>";
 foreach(
$_POST['prezzo'] as $key => $value) {
  print 
"prezzo chiave=$key valore=$value<br/>";
 } 
// foreach($_POST['prezzo'] as $key => $value)
 
print "<hr/>";       
 } 
// if ($_POST['bottone'] == "Invia")
// if (isset($_POST['bottone'])) ?>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form action="test319.php" method="post">
 <table>
  <th>Prodotto</th><th>Fornitore</th><th>Descrizione</th><th>Quantita</th><th>Prezzo</th><?php 
  $i
=1;
  for(
$i=1;$i<=10;$i++) { ?>
 <tr>
  <td><input type="text" name="prodotto[]" /></td>
  <td><input type="text" name="fornitore[]" /></td>
  <td><input type="text" name="descrizione[]" /></td>
  <td><input type="text" name="quantita[]" /></td>
  <td><input type="text" name="prezzo[]" /></td>
 </tr><?php 
 
// for($i=1;$i<=10;$i++) ?>
 </table>
 <input type="submit" value="Invia" name="bottone" />
</form>
</body>
</html>
Capito il concetto ?
Ok, grazie infinite per l'esempio ora mi resta solo una cosa da capire

io per inserire i dati in tabella, valorizzo prima le variabili tipo::

codice:
...
...
foreach($_POST['prezzo'] as $key => $value)
{
$this->prezzo = $_POST['prezzo'];
print "prezzo chiave=$key valore=$value<br/>";
} 
                
                    $dipendente = $_SESSION['id'];
                    
                    $query = "
                                INSERT INTO workpaper
                                SET 
                                    prodotto='".mysql_real_escape_string($this->prodotto)."',
                                    fornitore='".mysql_real_escape_string($this->fornitore)."',
                                    descrizione='".mysql_real_escape_string($this->descrizione)."',
                                    quantita='".mysql_real_escape_string($this->quantita)."',
                                    prezzo='".mysql_real_escape_string($this->prezzo)."',
                                    dipendente='".mysql_real_escape_string($dipendente)."'
                                    ";
Il problema è che ottengo questo messaggio:

Warning: mysql_real_escape_string() expects parameter 1 to be string, array given

che si presenta proprio alla prima riga della query, effettivamente si aspetta una stringa e non un array.