Hi members of OtLand!
I am having some problems to create a sort fuction in my code (For spells)
I am not sure where and how I shall add the sort function.
I would like that Spell Name to be sorted.
If I am unclear, Could you please tell me which part that's unclear!
Thanks in advance!
I am having some problems to create a sort fuction in my code (For spells)
PHP:
<style type="text/css">
td {
color: white;
height: 20px;
color: #666;
}
</style>
<?php
if(!defined('BASEPATH')) exit('No direct script access allowed');
$DIR = '*:/*/*/data/spells/';
if(is_dir($DIR)) {
$spells = simplexml_load_file($DIR.'spells.xml');
$table_color_1 = 'black';
$table_color_2 = '#080808';
?>
<h2>Spells</h2>
<table style= border="0px" cellspacing="0px" cellpadding="4px" width="100%">
<tr bgcolor="#101010 ">
<th style="color: #FF4500">Spell Name</th>
<th style="color: #FF4500">Words</th>
<th style="color: #FF4500">Mana Cost</th>
<th style="color: #FF4500">Level Required</th>
</tr>
<?php
$i = 1;
foreach($spells as $spell) {
$color = ($i % 2 ? $table_color_1 : $table_color_2);
$i++;
echo '
<tr bgcolor="'.$color.'" id="spell_list">
<td style="font-size: 10pt;">'.$spell['name'].'</td>
<td style="font-size: 10pt;">'.$spell['words'].'</td>
<td style="font-size: 10pt;">'.$spell['mana'].'</td>
<td style="font-size: 10pt;">'.$spell['lvl'].'</td>
</tr>';
}
}
else{alert('Error while loading spells. Directory address must be correct.');}
?>
</table>
I would like that Spell Name to be sorted.
If I am unclear, Could you please tell me which part that's unclear!
Thanks in advance!