mardi 26 septembre 2017

How to call that variable in other page (foreach)

I have this input module:

echo "<form action='inserisci.php' method='post'>";
echo "<input type='number' min='1' max='99' autocomplete='off' name='quantita' value='{$row['quantita']}'/>"

I insert in the field QUANTITA the values ​​extracted from mysql db, namely {$row['quantita']}.

The original values in the field, sometimes, has to be modified, but when i change they, on the next page (inserisci.php), it always returns only the values from the database and only the first quantita values that i have checked!!

FULL CODE:

            echo "<form action='inserisci.php' method='post' enctype='application/x-www-form-urlencoded'>";
            echo "<table align='left' border='10' width='40%'";
            echo "<tr><th></th><th>Qnt</th><th>Prodotto</th><th>Term</th><th>Data</th></tr>";

        foreach ($pdo->query("SELECT * FROM tabella") as $row) {

        echo "<tr><td><input type='checkbox' name='selected[]' value='{$row['id']}'/><br /></td><td>

        <input type='number' min='1' max='99' autocomplete='off' name='quantita' value='{$row['quantita']}'/>


    </td><td>{$row['prodotto']}</td><td>{$row['terminale']}</td><td>{$row['data']}</td></tr>";        }
        echo "</table>";        ?> 
//------------------------------------------------------------------------          
        <table width="500" border="10">
          <tr>
            <td width="987" align="center"><b>PRENOTAZIONE PRODOTTO</b></td>
          </tr>
          <tr>
            <td>
              <table width="633">
                <tr>
                  <td width="500">Nome:</td>
                    <td width="420" align="left"><input type="text" autocomplete="off" name="nome" size="70" onkeyup="maiuscola(this)"/>
                  </td>
                </tr>
                <tr>
                  <td width="500">Cognome:</td>
                    <td width="420" align="left"><input type="text" autocomplete="off" name="cognome" size="70" onkeyup="maiuscola(this)"/>
                  </td>
                </tr>
                <tr>
                  <td>Numero di tel.:</td>
                    <td width="420" align="left"><input type="text" step="any" size="20" autocomplete="off" min="1" name="numero"/>
                  </td>
                </tr>
                <tr>
                  <td>Note:</td>
                    <td width="420" align="left"><input type="text" autocomplete="off" size="70" name="note" onkeyup="maiuscola(this)"/>
                  </td>
                </tr>                                           
                <tr>
                  <td></td>

            <td align="left"><input style="width:100px;" type="submit" value="Inserisci"/>
                </tr>
                </form>
              </table>
            </td>
          </tr>
        </table>

inserisci.php

$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
$quantita = $_POST['quantita'];
$numero = $_POST['numero'];
$note = $_POST['note'];
    echo $quantita;




Aucun commentaire:

Enregistrer un commentaire