Well, i've made SOME progress. So far, I have created a function that baiscally detects if the ResultID rolls over to 1. If that is the case, it returns the number of results to display. However, it is not working correctly. Here is the code:
<?php
function get_sub_element_rows($element,$ind = 0){
$start_ind = 0;
while ($this->array_element[$element][$ind] != $start_ind AND $this->array_element[$element][$ind] != "")
{
$start_ind = 1;
$ind++;
}
return $ind;
}
?>
I call this function from within a for loop such as this:
<?php
for ($s = 0; $s < $xml->get_element_rows("Result"); $s++)
{
if (!$old_num_rows)
{
$old_num_rows == 0;
}
$num_rows = $xml->get_sub_element_rows("ResultID", $old_num_rows);
$old_num_rows = $old_num_rows + $num_rows;
}
?>
Now, for a test example, I used an XML file with 4 <Result> Tags as follows:
<Result>
<ResultID>1</ResultID>
</Result>
<Result>
<ResultID>1</ResultID>
<ResultID>2</ResultID>
<ResultID>3</ResultID>
</Result>
<Result>
<ResultID>1</ResultID>
<ResultID>2</ResultID>
</Result>
<Result>
<ResultID>1</ResultID>
<ResultID>2</ResultID>
<ResultID>3</ResultID>
<ResultID>4</ResultID>
</Result>
I ran this through the script, and at the beginning of the for loop, I echoed the values of $num_rows and $old_num_rows
Here are the results:
old_num_rows: 0
num_rows: 1
old_num_rows: 1
num_rows: 4
old_num_rows: 5
num_rows: 6
old_num_rows: 11
num_rows: 11
This is not correct. The difference between $num_rows and $old_num_rows should be exactly how many <ResultID> tags are under each <Result> tag. It appears to work for the first 2 results, but after that it becomes really screwed up. I know it has to be something simple, but my brain is fried right now.
Can anyone out here help me with this? I am really losing my mind. Thanks in advance.