Unknown Soldier
Mapping a map
- Joined
- Oct 30, 2010
- Messages
- 294
- Solutions
- 11
- Reaction score
- 665
Hello everyone,
I need your help with simple spells.php page on Gesior AAC.
I have a php file which creates a table from spells.xml from OTS data folder, but I have problem with last column which returns vocation for each spell. At the moment it reads every vocation which is in spells.xml and returns them all into one row - so one spell. Which is ofc not correct
It needs some kind of check, that if the spell name = x, then read vocations inside this spell and return them (with some kind of separator). Well it is probably really simple, but I have never learnt php, I had only some basics on c++ many years ago which is not really helping me now. The part of the code is between marks "//from here" and "//to here"
I would appreciate your help and of course give rep
I need your help with simple spells.php page on Gesior AAC.
I have a php file which creates a table from spells.xml from OTS data folder, but I have problem with last column which returns vocation for each spell. At the moment it reads every vocation which is in spells.xml and returns them all into one row - so one spell. Which is ofc not correct
It needs some kind of check, that if the spell name = x, then read vocations inside this spell and return them (with some kind of separator). Well it is probably really simple, but I have never learnt php, I had only some basics on c++ many years ago which is not really helping me now. The part of the code is between marks "//from here" and "//to here"
PHP:
<?php
if(!defined('INITIALIZED'))
exit;
$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B><font CLASS=white>Name</B></TD><TD CLASS=white><B><font CLASS=white>Sentence</B></TD><TD CLASS=white><B><font CLASS=white>Type</B></TD><TD CLASS=white><B><font CLASS=white>Mana</B></TD><TD CLASS=white><B><font CLASS=white>Level</B></TD><TD CLASS=white><B>Vocations:</B></TD></TR>';
$stages = new DOMDocument();
if($stages->load($config['site']['serverPath'] . 'data/spells/spells.xml'))
{
foreach($stages->getElementsByTagName('instant') as $stage)
{
if($stage->hasAttribute('group'))
{
if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['lightborder']; } else { $bgcolor = $config['site']['darkborder']; } $number_of_rows++;
$main_content .= '<TR BGCOLOR="'.$bgcolor.'"><TD>'.$stage->getAttribute('name').'</TD><TD>'.$stage->getAttribute('words').'</TD><TD>'.$stage->getAttribute('group').'</TD><TD>'.$stage->getAttribute('mana').'</TD><TD>'.$stage->getAttribute('lvl').'</TD>';
$main_content .= '<TD>';
//from here
foreach($stages->getElementsByTagName('vocation') as $stage2)
{
if($stage2->hasAttribute('name'))
{
$main_content .= ''.$stage2->getAttribute('name').'';
}
}
//to here
$main_content .= '</TD></TR>';
}
}
}
$main_content .= '</table>';
?>
I would appreciate your help and of course give rep