[FX.php List] Trying to read back an array

Dale Bengston dbengston at tds.net
Fri Sep 17 07:37:36 MDT 2010


Hi Bob,

I would try this syntax for setting your session variables:

		$_SESSION['description'][$recid] = $_POST['description'.$recid] ;
		$_SESSION['type'][$recid] = $_POST['type'.$recid] ;
		$_SESSION['serial']$recid] = $_POST['serial'.$recid] ;
		$_SESSION['problem'][$recid] = $_POST['problem'.$recid] ;
		$_SESSION['recid'][$recid] = $recid ;

... then your array $_SESSION['recid'] will actually have elements for each record.

Dale


On Sep 17, 2010, at 8:18 AM, Bob Patin wrote:

> Hi guys,
> 
> In my last episode our hero was trying to store input into arrays; he got that far...
> 
> Now he's trying to get this back, and here's the problem:
> 
> I store the POST values here:
> 
> // loop through the recid array and create the product arrays
> if( (strlen($_POST['recid'])>0) && (is_array($_POST['recid']))) {
> 	foreach($_POST['recid'] as $recid) {
> 		$_SESSION['description['.$recid.']'] = $_POST['description'.$recid] ;
> 		$_SESSION['type['.$recid.']'] = $_POST['type'.$recid] ;
> 		$_SESSION['serial['.$recid.']'] = $_POST['serial'.$recid] ;
> 		$_SESSION['problem['.$recid.']'] = $_POST['problem'.$recid] ;
> 		$_SESSION['recid['.$recid.']'] = $recid ;
> 	}
> }
> 
> I can return $recid with no trouble, so I'm fairly certain that all my session vars are getting populated.
> 
> NOW... I want to show these on the same page, and wrote this:
> 
> 	  <?php
> 	  // loop through the recid array and create requests for each item
> 		foreach($_SESSION['recid'] as $recid) {
> 			$status = "Open; pending manufacturer approval";
> 			$description = $_SESSION['description'.$recid];
> 			$problem = $_SESSION['problem'.$recid];
> 			$serial = $_SESSION['serial'.$recid];
> 			echo $recid;
> 	?>
> <<<< TABLE >>>>
> <?php
> }
> ?>
> 
> What am I missing here? My FOREACH doesn't return anything at all, and doesn't loop a single time.
> 
> Thanks,
> 
> 
> Bob Patin
> Longterm Solutions
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
> iChat: bobpatin
> FileMaker 9, 10 & 11 Certified Developer
> Member of FileMaker Business Alliance and FileMaker TechNet
> --
> Expert FileMaker Consulting 
> FileMaker Hosting for all versions of FileMaker
> PHP • Full email services • Free DNS hosting • Colocation • Consulting
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20100917/d36c8bb3/attachment.html


More information about the FX.php_List mailing list