I'm trying to get variables values, surname and name, that are inside a table in the same row and there is a check box near of that row and if checked shoaled get both the information but differently so I can put them in a database table
I've tried something with php but I'm not getting out of it
I create the table in this way.
<?php
include 'db_connect.php';
$sql="SELECT nome, cognome FROM informazioni";
if ($result = $db->query($sql)) {
echo '<table border="2" align="center" id="table">';
echo '<tr>'
. '<th>Cognome </th>'
. '<th>Nome</th>';
/* fetch associative array */
while ($row = $result->fetch_assoc()) {
echo '<tr>
<td>
<p>'.$row['cognome'].'</p>
</td>
<td>
<p>'.$row['nome'].'</p>
</td>
<td>
<input type="checkbox" name="nome_var[]" value="'.$row['id'].'">
</td>
</tr>';
}
echo '</table>';
/* free result set */
$result->free();
}
?>
and here is what I've tried to get the checked elements but doesn't work
<?php
$nome_var = $_POST['nome_var'];
if(is_array($nome_var){
$toinsert = "INSERT INTO pagamentiEffettuati
(cognome, nome)
VALUES ('$surname', '$name')";
echo "Elementi selezionati: ".count($nome_var)."<br/>";
echo "-> ".reset($nome_var);
while( $elemento = next($nome_var) )echo "-> $elemento <br/>";
}
?>
and there is what I've tried to get the checked elements but doesn't work
Aucun commentaire:
Enregistrer un commentaire