Delete record PROBLEM!!!!
Posted: Mon Sep 22, 2003 1:52 am
HI.
I have a problem when I try to delete a recor in my DB, my code is not working, when I hit in "ACEPTAR" which is the button to proced with the delete, nothing happen. In other codes I use this It work?????
NEED HELP!!!!!!!!!!!!!!
My code is:
Thanks for any help.
Mario
I have a problem when I try to delete a recor in my DB, my code is not working, when I hit in "ACEPTAR" which is the button to proced with the delete, nothing happen. In other codes I use this It work?????
NEED HELP!!!!!!!!!!!!!!
My code is:
Code: Select all
<?php
db_connect();
viewheader();
// separate out your SQL query - it'll make your life much easier in the long
// run.
$sql = "SELECT * FROM `$dbtable` WHERE `email1` = '{$_GET['email_busca']}' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
// be consistent about where you place braces on your statements.
if ($action == "suppr")
{
$res = "DELETE FROM $dbtable WHERE id = '$id'";
mysql_query ($res);
mysql_close($db);
//session_unregister("username");
//session_unregister("smartid");
//session_unset();
////session_destroy();
//$expire = 365*24*3600;
//setcookie("username","",time()-$expire,"/","");
//setcookie("smartid","",time()-$expire,"/","");
header("location: index.php");
}
if (mysql_num_rows($res) < 1) {
echo '<p style="margin: 30 0 10 0;">ESTE CORREO ELECTRÓNICO NO HA SIDO REGISTRADO!!!!</p>';
echo '<h4><a href="javascript:history.back()">Regresar</a></h4>';
} else {
// you need to start the table here if you want it to contain all of the
// records, if you put the start in the while loop you'll get one table
// and heading per record
?>
<h4>ESTOS SON LOS DATOS DEL USUARIO CONSULTADO</h4>
<!-- be consistent about using either single or double quotes around
your HTML
use CSS properly - then you won't have to use tags anymore
and delete all your tags -->
<!-- your table tags were a bit messy - missing closing tags and
strangely nested tables, I've tried to clean it up but I'm not
sure how well it worked -->
<table width="80%" border="0" cellpadding="1" cellspacing="0" class="textfield2">
<tr bgcolor="#F6F6F6">
<td valign="top" align="right">
- <a href='menu.php'>REGRESAR</a> - - <a href='logout.php'>SALIR</a> -
</td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="1" cellpadding="3" align="center">
<tr bgcolor="#F1F1F1">
<td valign="top" colspan="5"> </td>
</tr>
<tr bgcolor="#F6F6F6">
<th style="text-align: left;">Nombre</th>
<th style="text-align: left;">Email</th>
<th style="text-align: left;">Borrar</th>
</tr>
<?php
// format your code - use tabs to make it easier to follow.
while ($row = mysql_fetch_assoc($res)) {
?>
<!-- where does the $bgColor variable come from? -->
<tr bgcolor="<?php echo $bgColor; ?>">
<td valign="top">
<b><?php echo $row['nombre']; ?> <?php echo $row['apellido1']; ?> <?php echo $row['apellido2']; ?></b>
</td>
<td valign="top">
<a href="mailto:<?php echo $row['email1']; ?>"><?php echo $row['email1']; ?></a>
</td>
<td>
<input type="hidden" name="action" value="suppr">
<input type="submit" class="textfield" value="ACEPTAR">
</td>
</tr>
<?php
} // end while
?>
</table>
</td>
</tr>
</table>
<?php
} // end if
?>
?>Mario