954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XML POST child data, identify which parent related to

Hi There,

I have an XML file and I list them by check boxes, categorized by their parent (branch).
After selection of the check box, I take them and give the values $branch(only one at a time) and $roles(can be many eg. SBP|BNA) to web services. And run this web services as how many branch listed to store each selected roles under their branch code.

My problem is, as I list these xml by foreach statement, I can not identify which check box is related to which branch code.

Thank You for your help

MY XML (dynamic generated from DB)

<volunteer_roles>
<branch code="301" name="Cardiff and Caerphilly">
<role code="SBP" name="Breastfeeding Peer Supporter">N</role>
<role code="BNA" name="Branch Advertising ">N</role>
</branch>
<branch code="542" name="Ealing">
<role code="SBP" name="Breastfeeding Peer Supporter">N</role>
<role code="BNA" name="Branch Advertising ">N</role>
</volunteer_roles>


MY Index page $count = count($otherRoles->branch);
echo "Total Number of branch : $count <br/>";

// find branch names
foreach($otherRoles->branch as $item)
{
echo "<pre>";
echo "Branch - "."<b>"."$item[name] "."</b>";
// list branch roles for each of them
foreach ($otherRoles->branch->role as $second_gen) {

echo "<pre>";
if ($second_gen == "Y") {
echo " <font color=\"green\">"."Confirmed Role - "."</font>$second_gen[name] <font color=\"red\"><i>- Resign</i></font><input type=\"checkbox\" name=\"ResignOtherConfirmedroles[]\" value=\"$second_gen[code]\" > ";
} if ($second_gen == "N") {
echo "<font color=\"blue\">"."Available role - "."</font>$second_gen[name] <input type=\"checkbox\" name=\"rolesOtherRegister[]\" value=\"$second_gen[code]\" >";

}
}
}

Process Page (taking the selected roles)

$rolesOtherRegister = $_POST['rolesOtherRegister']; 

foreach ($rolesOtherRegister as $one_rolee) {
$sourcee .= $one_rolee."|";
}
kadriirdak
Light Poster
33 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

I sort it out..

I gave the branch code in

<input type=\"checkbox\" name=\"rolesOtherRegister[$item[code]][]\" value=\"$second_gen[code]\" >";

and I take it by foreach on the next page.

foreach($rolesOtherRegister as $item_code => $role_array)
kadriirdak
Light Poster
33 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

I sort it out..

I gave the branch code in
[CODE]\" >";


and I take it by foreach on the next page.

foreach($rolesOtherRegister as $item_code => $role_array)
kadriirdak
Light Poster
33 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: