Ver Mensaje Individual
  #5 (permalink)  
Antiguo 28/09/2010, 10:56
Avatar de ylellan
ylellan
 
Fecha de Ingreso: mayo-2010
Ubicación: en un lugar de Veracruz
Mensajes: 432
Antigüedad: 14 años
Puntos: 36
Respuesta: actualizacion e insercion de registros

corazon puedes hacer un select y verificar lo que dices

Código PHP:
//hacer conexion con base de datos
$b=mysql_query("select *from tabla") or die ("ERROR EN CONSULTA".mysql_error());;
$c=mysql_fetch_array($b);
do
{
if(
$c['activo']=='1')
{
$aux=$c['id'];
mysql_query("UPDATE tabla SET activo='0' where id='$aux'") or die("ERROR EN ACTUALIZAR".mysql_error());
}
}
while(
$c=myql_fetch_array($b));
mysql_query("INSERT INTO tabla(campos)VALUE('valores')") or die("ERROR EN INSERCCION".mysql_error());