I have a form like that:
<tr>
<td class="ttd"><input type="checkbox" value="<?php echo htmlentities($kunde['ID']); ?>" name="chk[]"> </td>
<td class="ttd"><?php echo htmlentities($kunde['ID']); ?> </td>
<td class="ttd"><?php echo htmlentities($kunde['tre']); ?> </td>
<td class="ttd"><?php echo htmlentities($kunde['zt']); ?> </td>
<td class="ttd"><?php echo htmlentities($kunde['jh']); ?> </td>
<td class="ttd"><?php echo htmlentities($kunde['nb']); ?> </td>
<td class="ttd"><?php echo htmlentities($kunde['ds']); ?> </td>
<td class="ttd"><?php echo htmlentities($kunde['yx']); ?> </td>
<td class="ttd" style="width:200px;"><?php echo htmlentities($x); ?> </td>
</tr>
and i want an output, that for each checkbox give me an ID, I write this Code:
$checked_array = $_POST['chk'];
$count = count($checked_array);
foreach($_POST['chk'] as $key => $kunde["ID"]){
for ($i=1; $i <= $count; $i++){
But that gives me just first ID. Anyone can help me?
update
So, I need a xml file with every checkbox, if i write echo, that gives me every ID or somthing appended attribut, but when i want to have a xml file, that gives me just first ID. this is my code as xml file:
$kunde_set = find_all_kunde();
while($kunde = mysqli_fetch_assoc($kunde_set)){
$res = mysqli_query($connection, 'SELECT COUNT(ID) AS id_count FROM company');
$rows = mysqli_fetch_assoc($res);
$count = $row['id_count'];
$result = mysqli_query($connection, 'SELECT SUM(Amount) AS Amount_sum FROM company');
$row = mysqli_fetch_assoc($result);
$sum = $row['Amount_sum'];
$Invoice_number = $kunde['Invoice_number'];
$Company_name = $kunde['Company_name'];
$Amount = $kunde['Amount'];
$Iban = $kunde['Iban'];
$tstamp = time();
$time = date("Y-m-d H:i:s", $tstamp);
$date = date("Y-m-07");
if(isset($_POST['submit'])){
$filename = "export_xml_".date("Y-m-d_H-i",time()).".xml";
$xml = new DOMDocument;
$xml->preserveWhiteSpace = FALSE;
$Document = $xml->appendChild($xml->createElement('Document'));
$Document_attribute = $xml->createAttribute('xmlns');
$Document_attribute->value = "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03";
$Document -> appendChild($Document_attribute);
$CstmrCdtTrfInitn = $xml->createElement('CstmrCdtTrfInitn');
$Document->appendChild($CstmrCdtTrfInitn);
$GrpHdr = $xml->createElement('GrpHdr');
$CstmrCdtTrfInitn->appendChild($GrpHdr);
$MsgId = $xml->createElement('MsgId', $tstamp);
$GrpHdr -> appendChild($MsgId);
$CreDtTm = $xml->createElement('CreDtTm', $time);
$GrpHdr -> appendChild($CreDtTm);
$NbOfTxs = $xml->createElement('NbOfTxs', $count);
$GrpHdr -> appendChild($NbOfTxs);
$CtrlSum = $xml->createElement('CtrlSum', $sum);
$GrpHdr -> appendChild($CtrlSum);
$Nm = $xml->createElement('Nm', 'Idependesk GmbH');
$InitgPty = $xml->createElement('InitgPty');
$InitgPty -> appendChild($Nm);
$GrpHdr -> appendChild($InitgPty);
$PmtInf = $xml->createElement('PmtInf');
$CstmrCdtTrfInitn->appendChild($PmtInf);
$PmtInfId = $xml->createElement('PmtInfId', $tstamp);
$PmtInf->appendChild($PmtInfId);
$PmtMtd = $xml->createElement('PmtMtd', 'TRF');
$PmtInf->appendChild($PmtMtd);
$BtchBookg = $xml->createElement('BtchBookg', false);
$PmtInf->appendChild($BtchBookg);
$NbOfTxs = $xml->createElement('NbOfTxs', $count );
$PmtInf->appendChild($NbOfTxs);
$CtrlSum = $xml->createElement('CtrlSum', $sum);
$PmtInf->appendChild($CtrlSum);
$Cd = $xml->createElement('Cd', 'SEPA');
$SvcLvl = $xml->createElement('SvcLvl');
$SvcLvl->appendChild($Cd);
$PmtTpInf = $xml->createElement('PmtTpInf');
$PmtTpInf -> appendChild($SvcLvl);
$PmtInf->appendChild($PmtTpInf);
$ReqdExctnDt = $xml->createElement('ReqdExctnDt', $date);
$PmtInf->appendChild($ReqdExctnDt);
$Nm = $xml->createElement('Nm', 'Idependesk GmbH');
$Dbtr = $xml->createElement('Dbtr');
$Dbtr -> appendChild($Nm);
$PmtInf->appendChild($Dbtr);
$IBAN = $xml->createElement('IBAN', 'DE23432423423423423442');
$Id = $xml->createElement('Id');
$Id -> appendChild($IBAN);
$DbtrAcct = $xml->createElement('DbtrAcct');
$DbtrAcct -> appendChild($Id);
$PmtInf->appendChild($DbtrAcct);
$BIC = $xml->createElement('BIC', 'gdgdfgdfgd');
$FinInstnId = $xml->createElement('FinInstnId');
$FinInstnId -> appendChild($BIC);
$DbtrAgt = $xml->createElement('DbtrAgt');
$DbtrAgt -> appendChild($FinInstnId);
$PmtInf->appendChild($DbtrAgt);
$checked_array = $_POST['chk'];
$count = count($checked_array);
foreach($_POST['chk'] as $key => $value){
#for ($i=1; $i <= $count; $i++){
if($_POST['chk'][$key]==$kunde["ID"]){
#echo $kunde['Company_name']."<br />";
#echo $kunde['Amount']."<br />";
$CdtTrfTxInf = $xml->createElement('CdtTrfTxInf');
$PmtInf->appendChild($CdtTrfTxInf);
$EndToEndId = $xml->createElement('EndToEndId', $Invoice_number);
$PmtId = $xml->createElement('PmtId');
$PmtId -> appendChild($EndToEndId);
$CdtTrfTxInf -> appendChild($PmtId);
$InstdAmt_attribute = $xml->createAttribute('Ccy');
$InstdAmt_attribute->value = "EUR";
$InstdAmt = $xml->createElement('InstdAmt', $Amount);
$InstdAmt -> appendChild($InstdAmt_attribute);
$Amt = $xml->createElement('Amt');
$Amt -> appendChild($InstdAmt);
$CdtTrfTxInf -> appendChild($Amt);
$BICC = $xml->createElement('BIC', 'BELA');
$FinInstnIdd = $xml->createElement('FinInstnId');
$FinInstnIdd -> appendChild($BICC);
$CdtrAgt = $xml->createElement('CdtrAgt');
$CdtrAgt -> appendChild($FinInstnIdd);
$CdtTrfTxInf -> appendChild($CdtrAgt);
$Nmm = $xml->createElement('Nm', $Company_name);
$Cdtr = $xml->createElement('Cdtr');
$Cdtr -> appendChild($Nmm);
$CdtTrfTxInf -> appendChild($Cdtr);
$IBANN = $xml->createElement('IBAN', $x);
$Idd = $xml->createElement('Id');
$Idd -> appendChild($IBANN);
$CdtrAcct = $xml->createElement('CdtrAcct');
$CdtTrfTxInf -> appendChild($Idd);
$Ustrd =$xml -> createElement('Ustrd', "independesk Gutschrift {$Invoice_number}");
$RmtInf = $xml->createElement('RmtInf');
$RmtInf -> appendChild($Ustrd);
$CdtTrfTxInf -> appendChild($RmtInf);
}
#}
$xml->formatOutput = true;
$xml->save('../includes/xml/'.$filename) or die('XML Create Error') ;
redirect_to("manage_content.php");
}
}
}
Aucun commentaire:
Enregistrer un commentaire