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."|";
}

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)

I sort it out..

I gave the branch code in

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

and I take it by foreach on the next page.

foreach($rolesOtherRegister as $item_code => $role_array)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.