Ver Mensaje Individual
  #11 (permalink)  
Antiguo 31/01/2015, 14:08
Drekazo
 
Fecha de Ingreso: enero-2015
Mensajes: 9
Antigüedad: 9 años, 2 meses
Puntos: 0
Respuesta: Eliminar registro tabla

Código PHP:
Ver original
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5.  
  6. <link rel="stylesheet" type="text/css" href="css.css">
  7. <title></title>
  8. </head>
  9. <body>
  10. <div id="mediodatos">
  11. <?php
  12.  
  13. //para hacer la conexion con mysql
  14. $host="localhost";
  15. $user="root";
  16. $pass="";
  17. $bd="miempresa";
  18.  
  19. include("borra.php");
  20. $nombre = isset($_POST['nombre']) ? $_POST['nombre'] : null ;
  21.  $apellidos =  isset($_POST['apellidos']) ? $_POST['apellidos'] : null ;
  22.  $fecha = isset($_POST['fecha']) ? $_POST['fecha'] : null ;
  23.  $nif = isset($_POST['nif']) ? $_POST['nif'] : null ;
  24.  $provincia = isset($_POST['provincia']) ? $_POST['provincia'] : null ;
  25.  
  26. //aqui la conexion con la BD e inserta datos del formulario
  27. $conex = mysqli_connect($host,$user,$pass,$bd);
  28.     if(!$conex){
  29.             echo "ERROR".mysqli_connect_error();
  30.            
  31.             }
  32. $sql = "INSERT INTO usuaris (nif, nom, cognoms, data_naix, provincia) VALUES ('$nif', '$nombre','$apellidos','$fecha','$provincia')";
  33.     if(!$sql){
  34.             echo "ERROR en la ejecucion de la sentencia".mysqli_connect_error();
  35.     }
  36. mysqli_query($conex,$sql);
  37.  
  38. $cadena="Select nif,nom,cognoms,data_naix,provincia from usuaris";
  39. $result=mysqli_query($conex,$cadena);
  40.         echo "<table id='miTabla' border=1  style='text-align: left; margin: auto;'>";
  41.         echo"<th><i>Nif</i></th><th><i>Nom</i></th><th><i>Cognoms</i></th><th><i>Data</i></th><th><i>Provincia</i></th>";
  42.         while($row=mysqli_fetch_array($result)) {
  43.                 echo( "<tr>
  44.                     <td>".$row['nif']."</td>
  45.                     <td>".$row['nom']."</td>
  46.                     <td>".$row['cognoms']."</td>
  47.                     <td>".$row['data_naix']."</td>
  48.                     <td>".$row['provincia']."</td>
  49.                     <td><a href='editar.php'>Editar</a></td>
  50.                    
  51.                     <td><a href='borra.php?$nif=".$row['nif']."'>Eliminar</a></td>;
  52.                 </tr>");   
  53.              }
  54.            
  55.          echo "</table>";  
  56. mysqli_close($conex);
  57.  
  58. ?><br>
  59.  
  60. <input type="button2" value="Volver" onClick="location.href='formulmysql.php'"class="boton2" />
  61. </div>
  62. </body>
  63. </html>