boton en php

Iniciado por jalbtercero, 20 Mayo 2016, 17:31 PM

0 Miembros y 1 Visitante están viendo este tema.

jalbtercero

Quiero que salga un boton para poder borrar el contenido de un <td> desde la base de datos, no me da error pero el boton no aparece.


Código (php) [Seleccionar]

<html>
<head>
<meta charset="UTF-9">
<style>
table {
width: 100%;
border-collapse: collapse;
}

table, th {
border: 1px solid black;
padding: 5px;
       

}
td {
        border: 1px solid black;
padding: 5px;
       
 
}

th {
        background-color: #4CAF50;
        color: white;
text-align: left;
}
</style>
<?php
    
if (isset($_POST['borrar_archivo'])) {
    require(
"connect_db2.php");
    if (
mysqli_query($link"DELETE FROM examenes WHERE asignatura = '{$_POST['archivo_id']}'")) {
        echo 
"<p>Archivo borrado correctamente!</p>";
        
mysqli_close($link);

    } else {
       echo 
"Error al conectar a base de datos";
}
}
?>

</head>
<body bgcolor="#8DC6FF">
<?php
require("connect_db2.php");
$borrar_html =
                
"<form action='' method='post'>
                    <input type='hidden' name='archivo_id' value='
{$resultados['id']}'/>
                    <button type='submit' name='borrar_archivo'>Borrar</button>
                 </form>"
;

function 
mostrarDatos($resultados) {
if($resultados !=NULL){
echo
            
"<tr>
        <td>
{$resultados['asignatura']}</td>
        <td>
{$resultados['dia']}</td>
                <td>
{$resultados['descripcion']}</td>
        <td>
                    
                  
$borrar_html
   
                </td>
    </tr>"
;
} else {

echo "<br/>No hay mas datos<br/>";
}
}


$result mysqli_query($link,"SELECT * FROM examenes");
echo 
"<table>
<tr>
<th>Asignatura</th>
<th>Dia</th>
<th>Descripcion</th>
                <th>Accion</th>
</tr>"
;
while(
$fila mysqli_fetch_array($result)) {
mostrarDatos($fila);
}
mysqli_free_result($result);
mysqli_close($link);
?>

</body>
</html>