Trying to sort listbox from XML file

Im trying to sort a list from and XML file but it wont sort, can anyone see where im going wrong??

[php] <?php
function getOptions($file, $element)
{
$xml = simplexml_load_file($file);
$results = $xml->xpath("//result/bandName");
usort($results, ‘cmp’);
function cmp($a,$b )
{
return strcmp($a, $b );
}
foreach($results as $res) {
$options .= “{$res}\n”;
}
return $options;
}
?>[/php]

          <form method="post" name="Band">
                  <select name="bandName">
                  <?php echo getOptions('xmldata.xml', 'bandName')?>
                  </select>
                  <input type="submit" name="btnSubmit" value="Search">
          </form>

[php] <?php
if (isset($_POST[‘btnSubmit’])) {
$xml = simplexml_load_file(‘xmldata.xml’);

    $search = $_POST['bandName'];
	
    $results = $xml->xpath("//result[bandName='$search']");
    echo "$search <br />";
    echo "<table>";
    echo "<tr>";
    echo "<td>"; 
    foreach ($results as $res) {
    echo "$res->year</td> <td style=\"width:175px\">$res->compName</td> <td style=\"width:175px\">$res->section</td><td>$res->position";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>"; 
    
    }
    echo "</table>";
    }
    ?> [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service