Hello everyone. I have loaded 2 XML files which have children elements with attributes. Both work correctly, they are tested. The problem is that i am trying to compare an attribute from the first XML with one from the other and it fails even though both files have the same values in a given attribute. More specifically I am loading <option> tags for a <select> tag from this:
Categories and their id's load normally in my app. Problem is when I try to make one selected. I try:HTML Code:<schoolcats> <category id="1">Cat 1</category> <category id="2">Cat 2</category> <category id="3">Cat 3</category> <category id="4">Cat 4</category> <category id="5">Cat 5</category> </schoolcats>
Every variable is tested and correct. Why won't the "if" give me a true when the loop finds the correct option though???PHP Code:<select name="schoolcat">
<?php
foreach ($schoolcats as $schoolcat) {
?>
<option value="<?=$schoolcat['id']?>"
<?php $test = $schoolcat['id'];
if ($test == $this_schoolcat) { echo ' selected="selected"'; } ?>><?=$schoolcat?></option>
<?php } ?>
</select>


Reply With Quote

Bookmarks