• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Spells.php

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 :D
spells.png


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 :)
 
Solution
Well, this the second time I write a question with help on support and again just a few minutes later I find solution myself... :D Anyway, I would like to share with you the final code, simple spells.php for gesior 1.0

Credits: NOT MINE CODE, just added working vocation column
Result:
spells.png


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...
Well, this the second time I write a question with help on support and again just a few minutes later I find solution myself... :D Anyway, I would like to share with you the final code, simple spells.php for gesior 1.0

Credits: NOT MINE CODE, just added working vocation column
Result:
spells.png


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>';
                foreach($stage->getElementsByTagName('vocation') as $stage2)               
                {
                    if($stage2->hasAttribute('name'))
                    {
                        $main_content .= ''.$stage2->getAttribute('name').'<BR>';
                    }
                }
            $main_content .= '</TD></TR>';
        }
    }
}
$main_content .= '</table>';
?>
 
Last edited:
Solution
Well, this the second time I write a question with help on support and again just a few minutes later I find solution myself... :D Anyway, I would like to share with you the final code, simple spells.php for gesior 1.0

Credits: NOT MINE CODE, just added working vocation column
Result:
spells.png


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>';
                foreach($stage->getElementsByTagName('vocation') as $stage2)              
                {
                    if($stage2->hasAttribute('name'))
                    {
                        $main_content .= ''.$stage2->getAttribute('name').'<BR>';
                    }
                }
            $main_content .= '</TD></TR>';
        }
    }
}
$main_content .= '</table>';
?>
its returning blank for me, no error in php...can u help?
 
Back
Top