0

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

Edited by mike_2000_17: Fixed formatting

1
Contributor
2
Replies
3
Views
6 Years
Discussion Span
Last Post by kadriirdak
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)

Edited by happygeek: fixed formatting

0

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)

Edited by Nick Evan: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.