Ver Mensaje Individual
  #9 (permalink)  
Antiguo 01/07/2015, 15:13
Avatar de xfxstudios
xfxstudios
 
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 10 meses
Puntos: 263
Respuesta: Insertar Array en mysql

listo elimine el foreach y dejo de repetir los registros, valga acotar que tengo un codigo de prueba encima de este y este deja de funcionar si elimino el otro si alguien sabe como hacer para que funcione solo sin el que voy a colocar les agradeceria:
Código PHP:
Ver original
  1. $first = date("Y-m-d");
  2. $last = ("2015-07-05");
  3. function dateRange( $first, $last, $step = '+1 day', $format = 'Y-m-d' ) {
  4.  
  5.     $dates = array();
  6.     $current = strtotime( $first );
  7.     $last = strtotime( $last );
  8.  
  9.     while( $current <= $last ) {
  10.  
  11.         $dates[] = date( $format, $current );
  12.         $current = strtotime( $step, $current );
  13.     }
  14.  
  15.     return $dates;
  16. }
No veo relacion entre el de arriba y este otr que es el que funciona solo con el de arriba, pero bueno, al menor funciona, seguire viendo a ver que paso alli:
Código PHP:
Ver original
  1. $fechaIni = (date("Y-m-d"));
  2. $fechaFin = ("2015-07-15");
  3. $nombre = "Carlos";
  4.  
  5. $fecha = ( dateRange( $fechaIni, $fechaFin, '+7 days') );
  6.  
  7. //foreach($nombre as $key=>$value)
  8. //    $nombre[]= $value;
  9.  
  10. //foreach($fecha as $key=>$value)
  11. //    $fecha[]= $value;
  12.  
  13. $conexion= mysql_connect($hostname_seguridad, $username_seguridad, $password_seguridad);
  14. mysql_select_db($database_seguridad, $conexion);
  15.  
  16. for($i=0; $i<count($fecha); $i++)
  17. {
  18.    mysql_query("INSERT INTO fecha (nombre, fecha) VALUES('$nombre' , '$fecha[$i]')",$conexion)or die(mysql_error());
  19.    
  20.    }
  21.    print_r( dateRange( $fechaIni, $fechaFin, '+7 days') );