Skip to content

Instantly share code, notes, and snippets.

@evilnapsis
Created September 2, 2019 07:52
Show Gist options
  • Save evilnapsis/9abe3453885b65d9789760ae42e3be8b to your computer and use it in GitHub Desktop.
Save evilnapsis/9abe3453885b65d9789760ae42e3be8b to your computer and use it in GitHub Desktop.
Codigo de la tabla donde se muestran los elementos para el proyecto eliminar elementos seleccionados con js, php y mysql
<a href="index.php?view=index&opt=new" class="btn btn-default"><i class='glyphicon glyphicon-user'></i> Nuevo</a>
<a href="javascript:void()" id="selectedall" class="btn btn-default"><i class='glyphicon glyphicon-th-list'></i> Seleccionar todos</a>
<a href="javascript:void()" id="delselected" class="btn btn-default"><i class='glyphicon glyphicon-remove'></i> Eliminar seleccionados</a>
<br><br>
<?php
$users = UserData::getAll();
if(count($users)>0){
?>
<div class="box box-primary">
<table class="table table-bordered datatable table-hover">
<thead>
<th>
</th>
<th>Nombre completo</th>
<th>Nombre de usuario</th>
<th></th>
</thead>
<?php
foreach($users as $user){
?>
<tr id="tr_<?php echo $user->id; ?>"> <!-- Agregamos el ID del usuario en el ID del elemento TR -->
<td style="width: 30px; ">
<input type="checkbox" id="item_<?php echo $user->id; ?>" class="myitem"> <!-- Agreamos el ID del usuario en el ID del check, ademas una clase -->
</td>
<td><?php echo $user->name." ".$user->lastname; ?></td>
<td><?php echo $user->username; ?></td>
<td style="width:120px;">
<a href="index.php?view=index&opt=edit&id=<?php echo $user->id;?>" class="btn btn-warning btn-xs">Editar</a>
<a href="index.php?action=users&opt=del&id=<?php echo $user->id;?>" class="btn btn-danger btn-xs">Eliminar</a>
</td>
</tr>
<?php
}
echo "</table></div>";
}else{
?>
<p class="alert alert-warning">No hay usuarios.</p>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment