Potete aiutarmi a creare una casella sulla tabella per ricercare con un id la rispettiva riga?
allego qui lo script
allego qui lo script
PHP:
<div class="elenco_utenti">
<div style="text-align:center; background:#1b1e24;"><span style="font-size: 22px; font-family: Verdana; "> AREA RISERVATA</span></div>
<div class='table-hover1'>
<form action='' method='POST' > <!-- IL FORM SARÀ TUTTA LA TABELLA -->
<table class="table1" >
<thead>
<tr>
<th class="intest1" colspan="4">DATI</th>
<th class="intest1" colspan="2">REGISTRO</th>
<th class="intest" rowspan="2">
<button class="fa fa-paper-plane " aria-hidden="true" name="bottone" title="conferma presenze"
type="submit" style="background:none; padding:0; color:gray;" >
</button>
<i onclick="show_form()" class='fa fa-user-plus fa-2x' aria-hidden='true'
title="inserisci utente al corso" style="color:gray;"> </i>
</th>
</tr>
<tr>
<th class="intest">ID</th>
<th class="intest">NOME</th>
<th class="intest">COGNOME</th>
<th class="intest">INFO</th>
<th class="intest">PRESENZA</th>
<th class="intest">ASSENZA</th>
<span class="show">
<!-- <th class="int more hidden">DATA DI NASCITA</th>
<th class="int more hidden">CODICE FISCALE</th>
<th class="int more hidden">LUOGO DI NASCITA</th> -->
</span>
</tr>
</thead>
<?php
include('conn_selez_db.php');
if(isset($_POST['bottone']) && isset($_POST["registro"])) {
$registro = $_POST["registro"]; // recupero l'array registro che contiente id e presenza degli utenti
foreach ($registro as $id => $presenza) {// per ogni coppia chiave->valore all'interno dell'array $registro
$insert = "INSERT INTO presenze (ID,PRESENZA_ASSENZA) VALUES ($id,'$presenza');"; //definisco la query
/*
N.B.: all'interno della query $id non è racchiuso tra apici
poiché nella mia tabella è definito come intero.
*/
if(!mysqli_query($conn,$insert)) { // se la query di inserimento fallisce...
echo "Errore".mysqli_error($conn)."<br>"; // e stampo il relativo errore mysql
}
}
echo "<script type='text/javascript'>alert('Presenza/assenza registrata')</script>";
}
if(isset($_POST['elimina']))
{
$elimina=$_POST["elimina"];
$delete = "DELETE FROM persone_inserite WHERE ID=".$elimina;
if (!mysqli_query($conn, $delete)) {
echo "<script type='text/javascript'> alert('Errore durante l eliminazione')";
}
}
$query = "SELECT * FROM persone_inserite ORDER BY id";
$result = mysqli_query($conn,$query) or die(mysqli_error($conn));
while($row = mysqli_fetch_array($result)) {
echo "
<tr class='tabr'>
<td class='tab' id='colonna_id'>" . $row['0'] . "</td>
<td class='tab' id='colonna_nome'>" . $row['1'] . "</td>
<td class='tab' id='colonna_cognome'>" . $row['2'] . "</td>
<td class='tab' id='colonna_info'>
<span id='info' class='main" . $row['0'] . " info'>
<i title='info' class='fa fa-info-circle fa-2x ' aria-hidden='true' style='color:gray;'></i>
</span>
</td>
<td class='tab' id='colonna_assenza'>
<input class='radio' id='ass$row[0]' type='radio' name='registro[$row[0]]' value='assente'> <label for='ass$row[0]'><strong>Assente</strong></label>
</td>
<td class='tab' id='colonna_presenza'>
<input class='radio' id='pre$row[0]' type='radio' name='registro[$row[0]]' value='presente'>
<label for='pre$row[0]'><strong>Presente</strong></label>
</td>
<td class='tab' id='colonna_bottoni'>
<button class='bottone' name='bottone' title='conferma presenza' type='submit' style='background:none; padding:0; color:gray; '>
<i class='fa fa-paper-plane fa-2x ' aria-hidden='true' ></i>
</button>
<button class='bottone' name='elimina' value='$row[0]' title='elmina utente' type='submit' style='background:none; padding:0; color:gray; '>
<i class='fa fa-trash-o fa-2x' aria-hidden='true' ></i>
</button>
</td>
</tr>
<td class='more" . $row['0'] . " hidden' colspan='2'><strong>Data di nascita:</strong></br>" . $row['3'] . "</td>
<td class='more" . $row['0'] . " hidden' colspan='2'><strong>CF:</strong></br>" . $row['4'] . "</td>
<td class='more" . $row['0'] . " hidden' colspan='2'><strong>Luogo di nascita:</strong></br>" . $row['5'] . "</td>
<script type='text/javascript'>
$('.main" . $row['0'] . "').click(function() {
$('.more" . $row['0'] . "').toggleClass('hidden');
$('.more').removeClass('hidden');
});
</script>
";
// il nOme di ogni input sarà un array che avrà come chiavi
// gli id degli utenti e come valori le rispettive presenze
}
?>
</table>
</form>
</div>