Forums

Values not being passed to array

chriso0258 20 Jan, 2016
Hello,

I have two tables (cn and mt). Both tables contain mac addresses but not all the mac addresses in table mt are in cn. Table mt contains passwords that I need to copy over to table cn to the corresponding mac address. I used the following code to determine that I am grabbing the correct information:
<?php

foreach ($form->data['cn'] as $keycn => $valuecn) 
{
	
	foreach ($form->data['mt'] as $keymt => $valuemt)
	{
		if ($valuecn[macAddress] == $valuemt[mac])
		{
			$valuecn[password] = $valuemt[password];
			echo "The cn mac address is: " . $valuecn[macAddress] . " and the password is: " . $valuecn[password] . "<br>";
		}
	}
	
}

?>


I'm getting the correct results
[attachment=0]macs.jpg[/attachment]

However, when I run the debugger right after this, the passwords are not being saved in the array, which I need to happen because I then need to save it to the db to save the passwords in the cn table.

[attachment=1]macs2.jpg[/attachment]

I'm obviously missing something. 😟 What do I need to do to save the data to the cn table?

Thanks for your help,
Chris
chriso0258 20 Jan, 2016
Answer
Hello,

I figured it out. I think I'm beginning to understand this array stuff a little better. The code I used was:

<?php

foreach ($form->data['cn'] as $keycn => $valuecn) 
{
	
	foreach ($form->data['mt'] as $keymt => $valuemt)
	{
		if ($valuecn[macAddress] == $valuemt[mac])
		{
			$form->data[cn][$keycn][password] = $valuemt[password];
		}
	}
	
}

?>


Then I added a dbSave action and set Multi save to yes. 😀
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger