Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/07/2005, 17:54
Avatar de tauro
tauro
 
Fecha de Ingreso: marzo-2002
Ubicación: Actualmente: Cd. Victoria
Mensajes: 222
Antigüedad: 22 años, 1 mes
Puntos: 0
mmm... ya lo metí aqui, verán, soy novato en php y nunca he utilizado esta instrucción, aqui pongo el código que utilizo:
Código:
<body>
<div id="Layer1" style="position:absolute; width:412px; height:115px; z-index:1; left: 6px; top: 14px;">
  <form name="form1" method="post" action="borrar.php">
    <p><span class="Estilo1">Introduzca el No. de ID a borrar: </span>      
      <input name="id" type="text" size="4" maxlength="4"> 
    </p>
    <p>&nbsp;</p>
    <div id="Layer2" style="position:absolute; width:51px; height:24px; z-index:2; left: 141px; top: 42px;">
      <input type="submit" name="Submit" value="Borrar">
</div>
    <p>&nbsp;</p>
  </form>
</div>
<p></p>
<br>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>

<?php
$link = mysql_connect("localhost", "root");
mysql_select_db("mydb", $link);
$result = mysql_query("SELECT id, nombre, email FROM agenda", $link);
echo "<table border = '2'> \n";
echo "<tr> \n";
echo "<td><b><center> Id </center></b></td> \n";
echo "<td><b><center> Nombre </center></b></td> \n";
echo "<td><b><center> E-Mail </center></b></td> \n";
echo "</tr> \n";
while ($row = mysql_fetch_row($result)){
echo "<tr> \n";
echo "<td><font face=verdana size=2>  $row[0]</td> \n";
echo "<td><font face=verdana size=2>  $row[1]</td> \n";
echo "<td><font face=verdana size=2>  $row[2]</td> \n";
echo "</tr> \n";
}
echo "</table> \n";
?>
</p>
<p>
  <?php

if(isset($id)){
	$link = mysql_connect("localhost", "root") or die ("No se pudo concretar la conexión");
	mysql_select_db("mydb",$link);
	$sql = "DELETE FROM agenda WHERE id = $id";
	$result = mysql_query($sql);
	header("localhost/php_mysql/borrar.php"); /* Redirect browser */
	

/* Make sure that code below does not get executed when we redirect. */
exit;

	} 
?>
Todo va junto, el fornulario y el codigo php, aqui muestro donde estoy poniendo el fragmento de codigo del header:
Código:
  <?php

if(isset($id)){
	$link = mysql_connect("localhost", "root") or die ("No se pudo concretar la conexión");
	mysql_select_db("mydb",$link);
	$sql = "DELETE FROM agenda WHERE id = $id";
	$result = mysql_query($sql);
	header("localhost/php_mysql/borrar.php"); /* Redirect browser */
	

/* Make sure that code below does not get executed when we redirect. */
exit;

	} 
?>
lo estoy poniendo en la segunda parte de php, donde borra el registro, lo pongo ahi y no me está haciendo nada, además de que estoy de forma local con apache por eso utilizo "localhost".
saludos!
__________________
Y entonces ví qué excelencias puede lograr un ingenio mediocre en un arte particular cuando emplea toda su vida en trabajar y afinarse en un único sentido... :arriba: