0

Hi to all stackoverflow users place the basic method directly in order to transmit data from one page to another via method = "POST" in PHP:

form.php:

<?php

session_start();

include '../connessione.php';

$id = $_SESSION['id'];

$query_string = "select * from ca2_2ac_clienti";

$query = mysqli_query($connessione, $query_string);

?>



<?php



while($row = mysqli_fetch_assoc($query)){ ?>

<form action="test.php" method="post">
    <input  name="text" value="<?php echo $row['id_cliente'] ;?>">
    <input type="submit" name="invia">
</form>

<?php } ?>

test.php:

<?php $text = $_POST['text']; ?>

<form action="test.php" method="post">
    <input  name="text" value="<?php echo $text;?>">
    <input type="submit" name="invia">
</form>

and up to here no problem, the problem arises when I want to implement this inside a table inside a while loop, ie inside my form in the value I do not see anything like it?

place the code:

<?php

 while($row = mysqli_fetch_array($result))
 {
?>
                <!--Table body-->
                <tbody>
                    <tr>
                        <th scope="row">
                            <label class="form-check-label" for="checkbox1" class="label-table"></label>
                        </th>
                        <form action="test.php" method="post">
                        <td style="vertical-align: middle;">
                        <input  name="text" value="<?php echo $row['codice_impianto'] ;?>">
                        </td>

                        <a href="#modifica<?php echo $row['id_impianto']; ?>" data-toggle="modal" class="btn btn-sm btn-warning btn-rounded"><span class="glyphicon glyphicon-edit"></span> MODIFICA</a> 

                        <a href="#elimina<?php echo $row['id_impianto']; ?>" data-toggle="modal" class="btn btn-sm btn-danger btn-rounded"><span class="glyphicon glyphicon-trash"></span> ELIMINA</a>
                        <input type="submit" name="invia">
                        </form>

                        <?php include('modali.php'); ?>




                        </td>



                    </tr>


                </tbody>

  <?php
}
 }
else
{
 echo 'Nessun risultato corrisponde alla tua ricerca';
}

?>
  • try to make your form in one cell not two and put your and in the **td** tags – Inazo Aug 24 '18 at 13:45
  • Why you using from in table and second one why you using body inside loop. You have only one table I think then why multiple tbody. – amku91 Aug 24 '18 at 13:46
  • Thanks sir. I fix immediatly! i solved put outside tag table form, and form work great –  Aug 24 '18 at 13:47

2 Answers2

0

The <form> element is not allowed to be a descendant of <table>, <tr> or <tbody> elements. You should place the <form> around the entire <table> element

Dajer
  • 108
  • 8
0

You should replace the <tbody> tags with <table> tags. The <tbody> tag can only be used inside a <table> tag, together with <thead>. Using it like this breaks your table layout.

You can read up on the proper use of this element at MDN.

wgrt
  • 1
  • 1