jeudi 22 janvier 2015

php echo not working after elseif

I am trying to extract data from an XML file using simplexml. I am running a series of while and foreach loops to dig down to what I need.


However, I have found that after the elseif is finished I can no long display additional data to the screen (echo and print_r don't work). I have attached a code snippet for the elseif loop through the end of the end of the script. Please excuse the lousy code, I am a relatively new programmer.



elseif ($select_vars[1]==-1) {
$sub1=0;
$sub2=0;
$temp_count = 1;
$modnum=intval($select_vars[0]);
$sub1m = $xmls->module->{
intval($select_vars[0])}

->count();
while ($sub1 < $sub1m) {
foreach($xmls->module->{
$modnum}

->sublist1->{
$sub1}

as $hit2){
$sub2m = $xmls->module->{
$modnum}

->sublist1->{
$sub1}

->count();
while ($sub2 < $sub2m) {
foreach($xmls->module->{
$modnum}

->sublist1->{
$sub1}

->sublist2->{
$sub2}

as $hit3){
$template_string .= $temp_count . " - " . (string)$hit3 . "<br/>";
$temp_count = $temp_count+1;
$template_list[] = (string)$hit3;
}

$sub2 = $sub2+1;
}

$sub1 = $sub1+1;
$sub2 = 0;
}

}

echo "sub1 = " . $sub1 . "<br/>";
}

echo "here <br/><br/>".$template_string;
print_r ($template_list);
$template_list = array_unique($template_list);
sort($template_list);
print_r ($template_list);


I know the loops extract the right information because I can echo anywhere in the various loops except after the esleif closing bracket.


A live copy of the code is available at: http://ift.tt/1E5UX6F


EDIT:


The output SHOULD be 3 selects and when the top box is filled when the others are empty a series of line (up to 400+) in the format ### - ####-####-####-#### should appear.


Aucun commentaire:

Enregistrer un commentaire