Guest User

Untitled

a guest
May 31st, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. <div class="table-responsive">
  2. <form action="checkruta.php" method="post" >
  3. <table class="table table-striped table-hover">
  4. <tr>
  5. <th>Folio </th>
  6. <th>Nombre</th>
  7. <th>Fecha solicitud</th>
  8. <th>Solicitud</th>
  9. <th>Estado</th>
  10. <th>Fecha Reporte</th>
  11. <th>Seleccionar Ruta</th>
  12. </tr>
  13. <?php
  14. if($filter){
  15. $sql = mysqli_query($con, "SELECT * FROM contribuyente WHERE estado='$filter' ORDER BY id ASC");
  16. }else{
  17. $sql = mysqli_query($con, "SELECT * FROM contribuyente ORDER BY id ASC");
  18. }
  19. if(mysqli_num_rows($sql) == 0){
  20. echo '<tr><td colspan="8">No hay datos.</td></tr>';
  21. }else{
  22. $no = 1;
  23. while($row = mysqli_fetch_assoc($sql)){
  24. echo '
  25. <tr>
  26. <td>'.$row['id'].'</td>
  27. <td><a href="profile.php?nik='.$row['nombre'].'"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> '.$row['nombre'].'</a></td>
  28. <td>'.$row['fecha'].'</td>
  29. <td>'.$row['mensaje'].'</td>
  30. <td>'.$row['estado'].'</td>
  31. <td>'.$row['fecha_rec'].'</td>
  32. <td> <input type="checkbox" name="id[]" value=<?php echo $row["id"]; ?></td>
  33.  
  34. <td>';
  35. if($row['estado'] == 'Resuelto'){
  36. echo '<span class="label label-success">Resuelto</span>';
  37. }
  38. else if ($row['estado'] == 'Pendiente' ){
  39. echo '<span class="label label-info">Pendiente</span>';
  40. }
  41. else if ($row['estado'] == 'Rechazado' ){
  42. echo '<span class="label label-warning">Rechazado</span>';
  43. }
  44. echo '
  45. </td>
  46.  
  47.  
  48. </tr>
  49. ';
  50. $no++;
  51. }
  52. }
  53. ?>
  54. </table>
  55. <input type="submit" name="autorizados" value="Autorizar seleccionados" />
  56. </div>
  57. </div>
  58. </div>
  59.  
  60. <?php
  61.  
  62. if (isset($_POST['autorizados'])) {
  63.  
  64. //Conexión Mysql.
  65. $db_host="localhost";
  66. $db_user="root";
  67. $db_password= "";
  68. $db_name="bdpagina";
  69. $db_connection = mysqli_connect($db_host, $db_user, $db_password, $db_name);
  70.  
  71.  
  72. $id = $_POST['id'];
  73. $count = count($id);
  74. $status = 'AUTORIZADA';
  75.  
  76. for ($i=0; $i < $count; $i++) {
  77.  
  78.  
  79. mysqli_query($db_connection,"UPDATE contribuyente SET ruta='$status'
  80. WHERE id='$id[$i]' LIMIT 1");
  81.  
  82. }
  83.  
  84. mysqli_close($db_connection);
  85. echo "Se actualizo correctamente";
  86. }
  87. ?>
  88.  
  89. $result=mysqli_query($db_connection,"UPDATE contribuyente SET ruta='$status'
  90. WHERE id='$id[$i]' LIMIT 1");
  91.  
  92. if($result){
  93. $message = "Consulta realizada.";
  94. } else {
  95. $message = "Se ha producido un error.";
  96. }
  97.  
  98. mysqli_close($db_connection);
  99. echo $message;
  100.  
  101. if ($db_connection->connect_error) {
  102. die("Error de conexión: " . $db_connection->connect_error);
  103. }
Add Comment
Please, Sign In to add comment