<?php
include "header.php";
include("config.php");
$id = $_GET["id"];
$updel = $_GET["updel"];
switch ($updel) {
// Query BD e creates the form
case "atualizar":
$consulta = "select * from $tabelabd where id=$id";
$resultado = mysql_query($consulta) or die("Cannot to delete");
$linha = mysql_fetch_array($resultado);
$id = $linha["id"];
$data = $linha["data"];
$nome = $linha["nome"];
$descricao = $linha["descricao"];
$link = $linha["link"];
echo "
<form action='upcad.php' method='post' name='update'>
<table border='1' width='430'><tr><input type='hidden' value='$id' name='id'>
<td width='50%'>Name:<br><input type='text' name='nome' size='26' value='$nome' maxlength='50'></td>
<td width='50%'>Link:<br><input type='text' name='link' size='26' value='$link' maxlength='100'></td>
</tr><tr>
<td width='100%' colspan='2'>Description:<br><input type='text' name='descricao' value='$descricao' size='56' maxlength='100'></td>
</tr><tr>
<td colspan='2' width='100%' align='center'><input type='reset' value='Refazer'> <input type='submit' name='upcad' value='$button_atualizar'></td>
</tr>
</table>
</form> ";
break;
// Query BD and deletes link
case "deletar":
$consulta = "select * from $tabelabd where id=$id";
$resultado = mysql_query($consulta) or die("Cannot to delete");
$linha = mysql_fetch_array($resultado);
$nomedeletado = $linha["nome"];
$deletar ="delete from $tabelabd where id=$id";
$excluir = mysql_query($deletar) or die ("Cannot to delete");
echo "<script type=\"text/javascript\">
function Redirecionar() {location.href = \"$link_admin\";}
window.setTimeout(\"Redirecionar()\", 2000); </script>";
echo "<font face='verdana,arial' size='2'>Link <b>$nomedeletado</b> deletado<br><br>Redirecting...</font>";
break;
default:
echo "It's not possible to execute this operation";
}
mysql_close($conexao);
include "footer.php";
?>