Jump to content

Really need help to Post to multi dimensional array useing my class


BrettCarr

Recommended Posts

Hi im new to forums and im not sure what i'm doing wrong I can't get an answer for my problem, am i setting it out wrong or somthing, I really need help

and im fairly new to php

I want to add the POST from a form to a multi dimensional array, I have started making a class called Batcharray, When the submit button is clicked It calls  Batcharray  This is whats in Batcharray

<?php
class Batcharray extends Database 
{









function getArrayData()
{

						$batch_date 				= $_POST['batch_date'];
						$batch_number 				= $_POST['batch_number'];
						$original_proof_num 		= $_POST['original_proof_num'];	
						$batch_status 				= $_POST['batch_status'];
						$invoice_num_ccaus 			= $_POST['invoice_num_ccaus'];
						$carrier 					= $_POST['carrier'];
						$num_of_boxes 				= $_POST['num_of_boxes'];
						$toll_consign_num 			= $_POST['toll_consign_num'];
						$custId 					= $_POST['custId'];
						$venueId 					= $_POST['venueId'];
						$bpay 						= $_POST['bpay'];
						$proof_tracking_comments 	= $_POST['proof_tracking_comments'];
						$veunue_comments 			= $_POST['veunue_comments'];


	$batchlist = array(	"batcharray" =>  array(	"batch_date" 				=> 	$batch_date,
											   	"batch_number"  		 	=> 	$batch_number ,
											   	"original_proof_num"  		=> 	$original_proof_num,	
											 	"batch_status" 				=> 	$batch_status,
											 	"invoice_num_ccaus" 		=> 	$invoice_num_ccaus,
											 	"carrier"					=> 	$carrier,
											 	"num_of_boxes"  			=> 	$num_of_boxes,
											 	"toll_consign_num"  		=> 	$toll_consign_num ,
											 	"custId"  					=>	$custId ,
											 	"venueId"  					=> 	$venueId,
											 	"bpay" 						=> 	$bpay,
											 	"proof_tracking_comments"	=> 	$proof_tracking_comments,
											 	"veunue_comments"			=> 	$veunue_comments,
									 )
							 	);







				/*$batchlist = array_merge((array)$batchlist,(array) $batcharray1);
				print_r( $batchlist );*/


				foreach( $batchlist["batcharray"] as $key => $value)
				{
					echo "$key, $value <br />";
				}
		reset($batchlist);
while (list($key, $val) = each($batchlist)) {
    echo "$key => $val\n";
}

}

}

?>

and it seem to  work for the first time can you help me add a new record I cannot for the life of me figure it out . this is what the out put says on first post

Array
(
    [batcharray] => Array
        (
            [batch_date] => 01-Jan-1970
            [batch_number] => 0
            [original_proof_num] => 596
            [batch_status] => New
            [invoice_num_ccaus] => 852
            [carrier] => Toll
            [num_of_boxes] => 5252
            [toll_consign_num] => 752752752
            [custId] => 75275275
            [venueId] => 752727
            [bpay] => 7427427
            [proof_tracking_comments] => 72
            [veunue_comments] => 272727272
        )

)

so thats where im at, do i need to use array_push, and if so How

 

Thanks in advance Brett

When you say adding a new record, are you re-submitting a form expecting the information being submitted to be added to the previous submission? If so how are you persisting the array? If your not, or you don't know what I'm talking about (which probably means your not), then that's your problem. With PHP variables/objects only exist from the time you call the script until the end of the script. Unless you are storing the array (ie persisting it) in a SESSION or some other persistent storage, the next time the script is called a new class object is created, thus explaining why you no longer have old values.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.