PHP - Obtener datos bidimencionales en php

 
Vista:
Imágen de perfil de Andres

Obtener datos bidimencionales en php

Publicado por Andres (11 intervenciones) el 06/10/2015 19:15:41
Saludos comunidad necesito enviar un arreglo bidimencional a mi base de datos pero no se como recibirlo en php
estos son mis codigos mis campos
1
<input type='text' readonly='readonly' id='fecha' name='fecha[][]' class='compa2' value='$row[0]'/></td>";
Este codigo envia los datos, todo funciona bien asta aqui.

1
2
3
4
5
6
7
8
9
$('.clsGuardar2').live('click', function () {
	$('#form_ejercicio').submit(function (msg) {
		alert($(this).serialize()); // check to show that all form data is being submitted
		$.post("ggrillamayor.php", $(this).serialize(), function (data) {
			alert(data); //post check to show that the mysql string is the same as submit                        
		});
		return false; // return false to stop the page submitting. You could have the form action set to the same PHP page so if people dont have JS on they can still use the form
	});
});

Aqui es el problema..
Este es el codigo con el que recibo mi array la cual no se en donde estoy haciendo mal para insertar varios datos en my tabla de mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$data = array_filter($_POST);
echo '<pre>';
$cone_tpdh = mysql_connect("localhost", "root", "alberto2791") or die("No se pudo realizar la conexion");
mysql_select_db("condata", $cone_tpdh) or die("ERROR con la base de datos");
print_r($data);
foreach ($data as $row) {
$sql_insertmayor = "INSERT INTO condata.t_mayor (fecha,cod_cuenta,cuenta,deb,hab,saldo,t_bl_inicial_idt_bl_inicial)
        VALUES (
           '".$row[0]."',
            '".$row[1]."',
            '".$row[2]."',
            '".$row[3]."',
            '".$row[4]."',
            '".$row[5]."',
            '".$row[6]."'
        )";
mysql_query($sql_insertmayor,$cone_tpdh);
}
 
echo '</pre>';
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder