Foros del Web » Programando para Internet » PHP »

hola como no duplicar un dato

Estas en el tema de hola como no duplicar un dato en el foro de PHP en Foros del Web. Cual es la instruccion en php para no sobre escriba datos en mi base cuando doy de alta un nuevo dato que verifique si ya ...
  #1 (permalink)  
Antiguo 25/02/2005, 12:31
Avatar de christopher1979  
Fecha de Ingreso: octubre-2004
Mensajes: 203
Antigüedad: 19 años, 6 meses
Puntos: 0
Exclamación hola como no duplicar un dato

Cual es la instruccion en php para no sobre escriba datos en mi base cuando doy de alta un nuevo dato que verifique si ya existe para no duplicarlo

gracias de ante mando
  #2 (permalink)  
Antiguo 25/02/2005, 13:00
Avatar de walo  
Fecha de Ingreso: mayo-2004
Mensajes: 310
Antigüedad: 19 años, 10 meses
Puntos: 0
Hace un query y en WHERE le pones el dato que se intenta agregar.
  #3 (permalink)  
Antiguo 25/02/2005, 13:12
Avatar de christopher1979  
Fecha de Ingreso: octubre-2004
Mensajes: 203
Antigüedad: 19 años, 6 meses
Puntos: 0
Exclamación hola no me quedo claro

me podrias poner un ejemplo no me quedo muy claro gracias por contestar
  #4 (permalink)  
Antiguo 25/02/2005, 13:21
Avatar de walo  
Fecha de Ingreso: mayo-2004
Mensajes: 310
Antigüedad: 19 años, 10 meses
Puntos: 0
Pasame el codigo asi veo como hace los querys y cuales son las variables
  #5 (permalink)  
Antiguo 25/02/2005, 13:22
Avatar de christopher1979  
Fecha de Ingreso: octubre-2004
Mensajes: 203
Antigüedad: 19 años, 6 meses
Puntos: 0
Exclamación aqui ay algo

$obraclavefrente = $_POST['obraclavefrente'];

$obranombrefrente = $_POST['obranombrefrente'];

$ubicacionfrente = $_POST['ubicacionfrente'];

$clavepartida = $_POST['clavepartida'];

$frentecalle = $_POST['frentecalle'];

$frentenumero = $_POST['frentenumero'];

$frentecolonia = $_POST['frentecolonia'];

$clavedestajista = $_POST['clavedestajista'];

$nombredestajista = $_POST['nombredestajista'];

$etapa = $_POST['etapa'];

$partidafecha = $_POST['partidafecha'];

$finalfecha = $_POST['finalfecha'];

$ano = $_POST['ano'];

$fecha = $_POST['fecha'];

$clavepaquete = $_POST['clavepaquete'];

$numeroestimacionletra = $_POST['numeroestimacionletra'];

$numeroestimacion = $_POST['numeroestimacion'];

$descpaquete = $_POST['descpaquete'];

$connection = mysql_connect("localhost","administrador","adminis trador");

mysql_select_db("destajos",$connection);

$datospaquete = mysql_query("SELECT * FROM paquetel where clavefrente = '$obraclavefrente' and clavepaquete = '$clavepaquete' and clavepartida = '$clavepartida'",$connection);

echo "<table>";

echo "<tr><td><font color = \"blue\" size = \"3\" face = \"arial\"><b>ESTIMACIONES (PASO3)<b></font></td></tr>";

echo "</table><br><br>";

echo "<table width = \"900px\">";

echo "<tr><td><font color = \"blue\" size = \"2\" face = \"arial\"><b>OBRA:</b></font><font color = \"green\" size = \"2\"><b>$obraclavefrente-$obranombrefrente</b></font></td>";

echo "<td><font color = \"blue\" size = \"2\" face = \"arial\"><b>FECHA:</b></font><font color =\"green\" size =\"2\"><b>$fecha</b></font></td>";

echo "<td><font color =\"blue\" size = \"2\" face = \"arial\"><b>LOCALIDAD:</b></font><font color = \"green\" size = \"2\"><b>$frentecalle $frentenumero Col. $frentecolonia</b></font></td></tr>";

echo "<tr><td><font color = \"blue\" size = \"2\" face = \"arial\"><b>FRENTE:</b></font<td><font color = \"green\" size = \"2\"><b>$ubicacionfrente</b></font></td>";

echo "<td><font color = \"blue\" size = \"2\" face = \"arial\"><b>ETAPA:</b></font><font color = \"green\" size = \"2\"><b>$etapa</b></font></td>";

echo "<td><font color = \"blue\" size = \"2\" face = \"arial\"><b>DESTAJISTA:</b></font><font color = \"green\" size = \"2\"><b>$clavedestajista-$nombredestajista</b></font></td></tr>";

echo "<tr><td><font color = \"blue\" size = \"2\" face = \"arial\"><b>PERIODO DE:</b></font><font color = \"green\" size = \"2\"><b>$partidafecha</b></font> <font color = \"blue\" size = \"2\" face = \"arial\"><b>AL:</b></font><font color = \"green\" size = \"2\"><b>$finalfecha $ano</b></font></td>";

echo "<td><font color = \"blue\" size = \"2\" face = \"arial\"><b>ESTIMANCION NUMERO:</b></font><font color = \"green\" size = \"2\"><b>  $numeroestimacion</b></font></Td></tr>";

echo "<tr><td><font color =\"blue\" size = \"2\" face = \"arial\"><b>TRABAJOS DE:</b></font><font color = \"green\" size = \"2\"><b>$clavepartida</b></font></td>";

echo "<td><font color = \"blue\" size = \"2\" face = \"arial\"><b>ESTIMACION NUMERO(con letra):</b></font><td><font color = \"green\" size = \"2\"><b>$numeroestimacionletra</b></font></td></tr>";

echo "</table><br><br>";

echo "<table border = \"1\">";

echo "<th><font size = \"2\"><b>Clave Concepto</b></font></th>";

echo "<th><font size = \"2\"><b>Concepto</b></font></th>";

echo "<th><font size = \"2\"><b>Unidad</b></font></th>";

echo "<th><font size = \"2\"><b>Precio Unitario</b></th>";

echo "<th><font size = \"2\"><b>Cantidad</b></th>";

echo "<th><font size = \"2\"><b>Volumen</b></th>";

echo "<th><font size = \"2\"><b>Importe</b></th>";


$datospaquete = mysql_query("SELECT * FROM paquetel where clavefrente = '$obraclavefrente' and clavepaquete = '$clavepaquete' and clavepartida = '$clavepartida' and descpaquete = '$descpaquete'",$connection);

while($rows = mysql_fetch_assoc($datospaquete)){

echo "<tr><td><font size = \"2\">$rows[claveconcepto]</td>";

echo "<td><font size = \"1\">$rows[descconcepto]</font></td>";

echo "<td><font size = \"1\">$rows[unidad]</font></td>";

echo "<td><font size = \"1\">$rows[pu]</font></td>";

echo "<td><font size = \"1\">$rows[cantidad]</font></td></tr>";

}
  #6 (permalink)  
Antiguo 25/02/2005, 13:37
Avatar de walo  
Fecha de Ingreso: mayo-2004
Mensajes: 310
Antigüedad: 19 años, 10 meses
Puntos: 0
ok, hace una cosa. Cuando alguien intente meter un registro, primero lo buscas a ver si esta

Código PHP:
$result mysql_query("SELECT * FROM paquetel where campo = '$registro_a_buscar'",$connection);

if(
mysql_num_rows($result)==0) {
//cargas el registro nuevo
} else {
// mandas el mensaje de que el registro ya existe

Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:46.