I am querying an API and getting XML results back. I am trying to take those results and stick them into a table that i have based on their status. Each column is a different status so they need to go in their respective columns. The problem i am running in to is when i have multiple items that are being returned with the same status. I believe this is breaking the loop. i am getting some items that are not appearing at all and some that are being duplicated. Any thoughts how i can acheive what i am looking for? Thanks!!
UPDATE with example xml:
<?xml version="1.0" encoding="UTF-8"?>
<Assets total="6">
<Asset>
<Attribute name="ID">B-1001</Attribute>
<Attribute name="Title">Some Bug #1</Attribute>
<Attribute name="Status">In Progress</Attribute>
</Asset>
<Asset>
<Attribute name="ID">B-1002</Attribute>
<Attribute name="Title">Some Bug #2</Attribute>
<Attribute name="Status">Code Review</Attribute>
</Asset>
<Asset>
<Attribute name="ID">B-1003</Attribute>
<Attribute name="Title">Some Bug #3</Attribute>
<Attribute name="Status">Code Review</Attribute>
</Asset>
<Asset>
<Attribute name="ID">B-1004</Attribute>
<Attribute name="Title">Some Bug #4</Attribute>
<Attribute name="Status">Ready for Development</Attribute>
</Asset>
<Asset>
<Attribute name="ID">B-1005</Attribute>
<Attribute name="Title">Some Bug #5</Attribute>
<Attribute name="Status">In Progress</Attribute>
</Asset>
<Asset>
<Attribute name="ID">B-1006</Attribute>
<Attribute name="Title">Some Bug #6</Attribute>
<Attribute name="Status">In Progress</Attribute>
</Asset>
<?php
foreach($xmlDefect as $assetDefect){
// variables from defects XML
$defectId = $assetDefect->Attribute[0];
$defectTitle = $assetDefect->Attribute[1];
$defectStatus = $assetDefect->Attribute[2];
if($defectStatus == "Gathering Requirements"){
$defectGatheringReqs = "<div class='bugsItem'>" . $defectId . "</div>";
}else if($defectStatus == "Ready for Development"){
$defectReadyForDev = "<div class='bugsItem'>" . $defectId . "</div>";
}else if($defectStatus == "In Progress"){
$defectInProgress = "<div class='bugsItem'>" . $defectId . "</div>";
}else if($defectStatus == "Code Review"){
$defectAEReview = "<div class='bugsItem'>" . $defectId . "</div>";
}else if($defectStatus == "Code Complete"){
$defectCodeComplete = "<div class='bugsItem'>" . $defectId . "</div>";
}
}
?>
<table>
<tr>
<td>
Gathering Requirements
</td>
<td>
Ready for Development
</td>
<td>
In Progress
</td>
<td>
Code Review
</td>
<td>
Code Complete
</td>
</tr>
<tr>
<td>
<?php echo $defectGatheringReqs; ?>
</td>
<td>
<?php echo $defectReadyForDev; ?>
</td>
<td>
<?php echo $defectInProgress; ?>
</td>
<td>
<?php echo $defectAEReview; ?>
</td>
<td>
<?php echo $defectCodeComplete; ?>
</td>
</tr>
</table>
$xmlDefect
? – George Cummins Jul 14 '11 at 21:52foreach
loop??? – Jon Jul 14 '11 at 22:24