Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/03/2012, 09:21
Avatar de OsSk4R
OsSk4R
 
Fecha de Ingreso: octubre-2006
Ubicación: $this->home
Mensajes: 824
Antigüedad: 17 años, 6 meses
Puntos: 74
Respuesta: Insertar multiples filas con foreach

Código PHP:
Ver original
  1. mysql_connect("localhost","","") or die("No se pudo conectar a la base de datos");
  2.  
  3. //SELECCIONAMOS LA BASE DE DATOS CON LA CUAL VAMOS A TRABAJAR CAMBIEN EL VALOR POR LA SUYA
  4.  
  5. foreach($_POST['tag'] as $valor) {
  6.        $qry = mysql_query("INSERT INTO t_tag_articulo (id_tag, id_articulo) VALUES ('".$valor."', '".$_POST['id_articulo']."')") or die("Query: $qry <br />Error: ".mysql_error());
  7. }

Saludos,