Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/03/2011, 09:03
Avatar de eddwinpaz
eddwinpaz
 
Fecha de Ingreso: noviembre-2007
Ubicación: Merida , Venezuela
Mensajes: 1.066
Antigüedad: 18 años, 11 meses
Puntos: 25
Respuesta: Multiples insert en PHP y HTML

Cita:
Iniciado por ArkangelGammar Ver Mensaje
Son arrays, y por lo que parece se corresponden la cantidad de objetos, yo te aconsejaria que haga algo asi:


Código PHP:
$i  = 0;
$x = //cantidad de objetos que te pasan desde el formulario
while($i < $x){

$datasheet->add_request_technical_dsheet($idrequest[$i], $file_path[$i], $file_type[$i], $qty[$i], $unit[$i], $price[$i], $paking[$i], $specification[$i], $comments[$i]);
$i = $i + 1;
} 
Obviamente acordate de asignar los arrays a cada una de las variables puestas en el add_request...

espero haber ayudado.

Saludos
segui el ejemplo que me distes pero me lanza los siguientes errores.

[16-Mar-2011 15:00:55] PHP Notice: Undefined index: idrequest in C:\Program Files (x86)\Zend\Apache2\htdocs\taihan_application\new_r equest.php on line 376
[16-Mar-2011 15:00:55] PHP Notice: Undefined index: file_path in C:\Program Files (x86)\Zend\Apache2\htdocs\taihan_application\new_r equest.php on line 377
[16-Mar-2011 15:00:55] PHP Notice: Undefined index: file_type in C:\Program Files (x86)\Zend\Apache2\htdocs\taihan_application\new_r equest.php on line 378
[16-Mar-2011 15:00:55] PHP Notice: Undefined index: unit in C:\Program Files (x86)\Zend\Apache2\htdocs\taihan_application\new_r equest.php on line 380
[16-Mar-2011 15:00:55] PHP Notice: Undefined index: price in C:\Program Files (x86)\Zend\Apache2\htdocs\taihan_application\new_r equest.php on line 381


con el siguiente codigo.

Código PHP:
               $project_name = $_POST['project_name'];
                                        
$client_name = $_POST['client_name'];
                                        
$final_client = $_POST['final_client'];
                                        
$countryid = $_POST['countryid'];
                                        
$request_due_date = $_POST['request_due_date'];
                                        
$notes = $_POST['notes'];
                                        
$contact_name = $_POST['contact_name'];
                                        
$contact_lastname = $_POST['contact_lastname'];
                                        
$contact_phone = $_POST['contact_phone'];
                                        
$contact_country = $_POST['contact_country'];

                                        
//
                                        
$idrequest = $_POST['idrequest'];
                                        
$file_path = $_POST['file_path'];
                                        
$file_type = $_POST['file_type'];
                                        
$qty = $_POST['qty'];
                                        
$unit = $_POST['unit'];
                                        
$price = $_POST['price'];
                                        
$paking = $_POST['paking'];
                                        
$specification = $_POST['specification'];
                                        
$comments = $_POST['comments'];
                                        
//
                                        

                                        
if ($request->add_request($project_name, $client_name, $final_client, $countryid, $request_due_date, $notes, $contact_name, $contact_lastname, $contact_phone, $contact_country)) {

                                            
$tools->message_show('ok', 'The Request has been successfully added!');

                                            if (
$_POST['theValue'] > 0) {

                                                
$i = 0;
                                                
$x = $_POST['theValue'];
                                                while (
$i < $x) {

                                                
$datasheet->add_request_technical_dsheet($request->id_query(), $file_path[$i], $file_type[$i], $qty[$i], $unit[$i], $price[$i], $paking[$i], $specification[$i], $comments[$i]);
                                                    echo 
$i;
                                                    
$i = $i + 1;
                                                }
                                            } 

[16-Mar-2011 15:00:55] PHP Notice: Undefined index: comments in C:\Program Files (x86)\Zend\Apache2\htdocs\taihan_application\new_r equest.php on line 384
__________________
O nos hacemos miserables o nos hacemos fuertes , la cantidad de trabajo es la misma.