• 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!

Gesior Advanced Spells.php

Adorius Black

Advanced OT User
Joined
Mar 31, 2020
Messages
301
Solutions
3
Reaction score
180
Hi. I was searching long time for page spells.php which has posibility to sort spells by vocation you choose.
I would like something like this:
spells.png


I found something like this:

PHP:
<?PHP
$allowed_order_by = array('name', 'spell', 'spell_type', 'mana', 'lvl', 'mlvl', 'soul');
$vocation_id = $_REQUEST['vocation_id'];
$order = $_REQUEST['order'];
if(in_array($order, $allowed_order_by))
    $orderby = $order;
else
    $orderby = 'name';

$spells = $SQL->query('SELECT * FROM z_spells WHERE hide_spell != 1 ORDER BY '.$orderby.', lvl');
$main_content .= '<FORM ACTION="?subtopic=spells" METHOD=post>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Spell Search</B></TD></TR>
<TR BGCOLOR='.$config['site']['darkborder'].'><TD>Only for vocation: <SELECT NAME="vocation_id">';
$main_content .= '<OPTION VALUE="a:a" ';
if('a:a' == $vocation_id)
    $main_content .= 'SELECTED';
$main_content .= '>All';

foreach($vocation_name[0] as $prom => $arr)
    foreach($arr as $voc_id => $voc_name)
    {
        $main_content .= '<OPTION VALUE="'.$prom.';'.$voc_id.'"';
        if($prom.';'.$voc_id == $vocation_id && $vocation_id != "a:a" && $vocation_id != '')
            $main_content .= ' SELECTED';
        $main_content .= '/>'.$voc_name;
    }
$main_content .= '</SELECT><input type="hidden" name="order" value="'.$orderby.'">&nbsp;&nbsp;&nbsp;<INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD><TR>
</TABLE></FORM>';

$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=name"><font CLASS=white>Name</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=spell"><font CLASS=white>Sentence</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=spell_type"><font CLASS=white>Type<br/>(count)</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=mana"><font CLASS=white>Mana</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=lvl"><font CLASS=white>Exp.<br/>Level</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=mlvl"><font CLASS=white>Magic<br/>Level</a></B></TD><TD CLASS=white><B><a href="?subtopic=spells&vocation_id='.$vocation_id.'&order=soul"><font CLASS=white>Soul</a></B></TD><TD CLASS=white><B>PACC</B></TD><TD CLASS=white><B>For<br/>Vocations:</B></TD></TR>';
if($vocation_id != 'a:a' && $vocation_id != '')
{
    foreach($vocation_name[0] as $prom => $arr)
        foreach($arr as $voc_id => $voc_name)
            if($prom.';'.$voc_id == $vocation_id)
                $voc_n = $voc_name;
    foreach($spells as $spell)
    {
        $spell_vocations = explode(",", $spell['vocations']);
        if(in_array($vocation_id, $spell_vocations) || empty($spell['vocations']))
        {
            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>'.$spell['name'].'</TD><TD>'.$spell['spell'].'</TD>';
            if($spell['spell_type'] == 'conjure')
                $main_content .= '<TD>'.$spell['spell_type'].'('.$spell['conj_count'].')</TD>';
            else
                $main_content .= '<TD>'.$spell['spell_type'].'</TD>';
            $main_content .= '<TD>'.$spell['mana'].'</TD><TD>'.$spell['lvl'].'</TD><TD>'.$spell['mlvl'].'</TD><TD>'.$spell['soul'].'</TD><TD>'.$spell['pacc'].'</TD><TD>'.$voc_n.'</TD></TR>';
        }
    }
}
else
{
    foreach($spells as $spell)
    {
        $spell_vocations = explode(",", $spell['vocations']);
        $showed_vocations = 0;
        $vocs = '';
        foreach($spell_vocations as $voc)
        {
            $voc_info = explode(";", $voc);
            if(!empty($vocation_name[0][$voc_info[0]][$voc_info[1]]))
            {
                $vocs .= $vocation_name[0][$voc_info[0]][$voc_info[1]];
                if($showed_vocations != count($spell_vocations))
                    $vocs .= '<br/>';
            }
        }
        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>'.$spell['name'].'</TD><TD>'.$spell['spell'].'</TD>';
        if($spell['spell_type'] == 'conjure')
            $main_content .= '<TD>'.$spell['spell_type'].'('.$spell['conj_count'].')</TD>';
        else
            $main_content .= '<TD>'.$spell['spell_type'].'</TD>';
        $main_content .= '<TD>'.$spell['mana'].'</TD><TD>'.$spell['lvl'].'</TD><TD>'.$spell['mlvl'].'</TD><TD>'.$spell['soul'].'</TD><TD>'.$spell['pacc'].'</TD><TD><font size="1">'.$vocs.'</font></TD></TR>';
    }
}

$main_content .= '</TABLE>';
?>

when i use it it looks like first picture but doesnt show any spells only this error:
Warning: Invalid argument supplied for foreach () on line 20 and 55.

I guess there is problem that i dont have z_spells in my SQL.
Is here anybody who know how to do it or fix it?

Thank you
 
Yes it's the problem that you don't have z_spells in your SQL.

The problem is, you have invalid argument supplied for foreach.

You need to investigate more.
 
Found z_spells but with line 20 I am totaly lost :D

SQL:
CREATE TABLE `z_spells` (
  `name` varchar(255) NOT NULL,
  `spell` varchar(255) NOT NULL,
  `spell_type` varchar(255) NOT NULL,
  `mana` int(11) NOT NULL DEFAULT 0,
  `lvl` int(11) NOT NULL DEFAULT 0,
  `mlvl` int(11) NOT NULL DEFAULT 0,
  `soul` int(11) NOT NULL DEFAULT 0,
  `pacc` varchar(255) NOT NULL,
  `vocations` varchar(255) NOT NULL,
  `conj_count` int(11) NOT NULL DEFAULT 0,
  `hide_spell` int(11) NOT NULL DEFAULT 0
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


INSERT INTO `z_spells` (`name`, `spell`, `spell_type`, `mana`, `lvl`, `mlvl`, `soul`, `pacc`, `vocations`, `conj_count`, `hide_spell`) VALUES
('Conjure Spear', 'exevo spear', 'conjure', 25, 6, 0, 1, 'no', '0;3,1;3', 1, 0),
('Conjure Blank Rune', 'adori blank', 'conjure', 40, 6, 0, 1, 'no', '0;1,1;1,0;2,1;2', 1, 0),
('Conjure Arrow', 'exevo con', 'conjure', 100, 13, 0, 1, 'no', '0;3,1;3', 10, 0),
('Poisoned Arrow', 'exevo con pox', 'conjure', 130, 16, 0, 2, 'no', '0;3,1;3', 7, 0),
('Conjure Bolt', 'exevo con mort', 'conjure', 140, 17, 0, 2, 'no', '0;3,1;3', 5, 0),
('Conjure Sniper Arrow', 'exevo con hur', 'conjure', 160, 24, 0, 3, 'no', '0;3,1;3', 5, 0),
('Explosive Arrow', 'exevo con flam', 'conjure', 290, 25, 0, 3, 'no', '0;3,1;3', 8, 0),
('Conjure Piercing Bolt', 'exevo con grav', 'conjure', 180, 33, 0, 3, 'no', '0;3,1;3', 5, 0),
('Enchant Staff', 'exeta vis', 'conjure', 80, 41, 0, 0, 'no', '1;1', 0, 0),
('Enchant Spear', 'exeta con', 'conjure', 350, 45, 0, 3, 'no', '0;3,1;3', 0, 0),
('Power Bolt', 'exevo con vis', 'conjure', 800, 59, 0, 4, 'no', '1;3', 10, 0),
('Poison Field', 'adevo grav pox', 'conjure', 200, 14, 0, 1, 'no', '0;1,0;2,1;1,1;2', 3, 0),
('Light Magic Missile', 'adori min vis', 'conjure', 120, 15, 0, 1, 'no', '0;1,0;2,1;1,1;2', 10, 0),
('Fire Field', 'adevo grav flam', 'conjure', 240, 15, 0, 1, 'no', '0;1,0;2,1;1,1;2', 3, 0),
('Fireball', 'adori flam', 'conjure', 460, 27, 0, 3, 'no', '0;1,1;1', 5, 0),
('Energy Field', 'adevo grav vis', 'conjure', 320, 18, 0, 2, 'no', '0;1,0;2,1;1,1;2', 3, 0),
('Stalagmite', 'adori tera', 'conjure', 400, 24, 0, 2, 'no', '0;1,1;1,0;2,1;2', 10, 0),
('Great Fireball', 'adori mas flam', 'conjure', 530, 30, 0, 3, 'no', '0;1,1;1', 4, 0),
('Heavy Magic Missile', 'adori vis', 'conjure', 350, 25, 0, 2, 'no', '0;1,1;1,0;2,1;2', 10, 0),
('Poison Bomb', 'adevo mas pox', 'conjure', 520, 25, 0, 2, 'no', '0;2,1;2', 2, 0),
('Firebomb', 'adevo mas flam', 'conjure', 600, 27, 0, 4, 'no', '0;1,0;2,1;1,1;2', 2, 0),
('Soulfire', 'adevo res flam', 'conjure', 600, 27, 0, 3, 'no', '0;1,0;2,1;1,1;2', 3, 0),
('Poison Wall', 'adevo mas grav pox', 'conjure', 640, 29, 0, 3, 'no', '0;1,0;2,1;1,1;2', 4, 0),
('Explosion', 'adevo mas hur', 'conjure', 570, 31, 0, 4, 'no', '0;1,0;2,1;1,1;2', 6, 0),
('Fire Wall', 'adevo mas grav flam', 'conjure', 780, 33, 0, 4, 'no', '0;1,0;2,1;1,1;2', 4, 0),
('Energybomb', 'adevo mas vis', 'conjure', 880, 37, 0, 5, 'no', '0;1,1;1', 2, 0),
('Energy Wall', 'adevo mas grav vis', 'conjure', 1000, 41, 0, 5, 'no', '0;1,0;2,1;1,1;2', 4, 0),
('Sudden Death', 'adori gran mort', 'conjure', 985, 45, 0, 5, 'no', '0;1,1;1', 3, 0),
('Antidote Rune', 'adana pox', 'conjure', 200, 15, 0, 1, 'no', '0;2,1;2', 1, 0),
('Intense Healing Rune', 'adura gran', 'conjure', 240, 15, 0, 2, 'no', '0;2,1;2', 1, 0),
('Ultimate Healing Rune', 'adura vita', 'conjure', 400, 24, 0, 3, 'no', '0;2,1;2', 1, 0),
('Convince Creature', 'adeta sio', 'conjure', 200, 16, 0, 3, 'no', '0;2,1;2', 1, 0),
('Animate Dead', 'adana mort', 'conjure', 600, 27, 0, 5, 'no', '0;1,0;2,1;1,1;2', 1, 0),
('Chameleon', 'adevo ina', 'conjure', 600, 27, 0, 2, 'no', '0;2,1;2', 1, 0),
('Destroy Field', 'adito grav', 'conjure', 120, 17, 0, 2, 'no', '0;1,0;2,0;3,1;1,1;2,1;3', 3, 0),
('Desintegrate', 'adito tera', 'conjure', 200, 21, 0, 3, 'no', '0;1,0;2,0;3,1;1,1;2,1;3', 3, 0),
('Magic Wall', 'adevo grav tera', 'conjure', 750, 32, 0, 5, 'no', '0;1,1;1', 3, 0),
('Wild Growth', 'adevo grav vita', 'conjure', 600, 27, 0, 5, 'no', '0;2,1;2', 2, 0),
('Paralyze', 'adana ani', 'conjure', 1400, 54, 0, 3, 'no', '0;2,1;2', 1, 0),
('Icicle', 'adori frigo', 'conjure', 460, 28, 0, 3, 'no', '0;2,1;2', 5, 0),
('Avalanche', 'adori mas frigo', 'conjure', 530, 30, 0, 3, 'no', '0;2,1;2', 4, 0),
('Stone Shower', 'adori mas tera', 'conjure', 430, 28, 0, 3, 'no', '0;2,1;2', 4, 0),
('Thunderstorm', 'adori mas vis', 'conjure', 430, 28, 0, 3, 'no', '0;1,1;1', 4, 0),
('Holy Missile', 'adori san', 'conjure', 350, 27, 0, 3, 'no', '0;3,1;3', 5, 0),
('Death Strike', 'exori mort', 'instant', 20, 16, 0, 0, 'no', '0;1,0;2,1;1,1;2', 0, 0),
('Flame Strike', 'exori flam', 'instant', 20, 12, 0, 0, 'no', '0;1,0;2,1;1,1;2', 0, 0),
('Energy Strike', 'exori vis', 'instant', 20, 12, 0, 0, 'no', '0;1,0;2,1;1,1;2', 0, 0),
('Whirlwind Throw', 'exori hur', 'instant', 40, 15, 0, 0, 'no', '0;4,1;4', 0, 0),
('Fire Wave', 'exevo flam hur', 'instant', 25, 18, 0, 0, 'no', '0;1,1;1', 0, 0),
('Ethereal Spear', 'exori con', 'instant', 25, 23, 0, 0, 'no', '0;3,1;3', 0, 0),
('Energy Beam', 'exevo vis lux', 'instant', 40, 23, 0, 0, 'no', '0;1,1;1', 0, 0),
('Great Energy Beam', 'exevo gran vis lux', 'instant', 110, 29, 0, 0, 'no', '0;1,1;1', 0, 0),
('Groundshaker', 'exori mas', 'instant', 160, 33, 0, 0, 'no', '0;4,1;4', 0, 0),
('Berserk', 'exori', 'instant', 115, 35, 0, 0, 'no', '0;4,1;4', 0, 0),
('Energy Wave', 'exevo vis hur', 'instant', 170, 38, 0, 0, 'no', '0;1,1;1', 0, 0),
('Rage of the Skies', 'exevo gran mas vis', 'instant', 650, 55, 0, 0, 'no', '0;1,1;1', 0, 0),
('Fierce Berserk', 'exori gran', 'instant', 340, 70, 0, 0, 'no', '0;4,1;4', 0, 0),
('Hells Core', 'exevo gran mas flam', 'instant', 1200, 60, 0, 0, 'no', '0;1,1;1', 0, 0),
('Divine Missile', 'exori san', 'instant', 20, 40, 0, 0, 'no', '0;3,1;3', 0, 0),
('Divine Caldera', 'exevo mas san', 'instant', 160, 50, 0, 0, 'no', '0;3,1;3', 0, 0),
('Eternal Winter', 'exevo gran mas frigo', 'instant', 1200, 60, 0, 0, 'no', '0;2,1;2', 0, 0),
('Ice Strike', 'exori frigo', 'instant', 20, 15, 0, 0, 'no', '0;1,1;1,0;2,1;2', 0, 0),
('Ice Wave', 'exevo frigo hur', 'instant', 25, 18, 0, 0, 'no', '0;2,1;2', 0, 0),
('Terra Strike', 'exori tera', 'instant', 20, 13, 0, 0, 'no', '0;1,1;1,0;2,1;2', 0, 0),
('Terra Wave', 'exevo tera hur', 'instant', 210, 38, 0, 0, 'no', '0;2,1;2', 0, 0),
('Wrath of Nature', 'exevo gran mas tera', 'instant', 770, 55, 0, 0, 'no', '0;2,1;2', 0, 0),
('Light Healing', 'exura', 'instant', 20, 9, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Antidote', 'exana pox', 'instant', 30, 10, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Intense Healing', 'exura gran', 'instant', 70, 11, 0, 0, 'no', '0;1,0;2,0;3,1;1,1;2,1;3', 0, 0),
('Heal Friend', 'exura sio', 'instant', 140, 18, 0, 0, 'no', '0;2,1;2', 0, 0),
('Ultimate Healing', 'exura vita', 'instant', 160, 20, 0, 0, 'no', '0;1,0;2,0;3,1;1,1;2,1;3', 0, 0),
('Mass Healing', 'exura gran mas res', 'instant', 150, 36, 0, 0, 'no', '0;2,1;2', 0, 0),
('Divine Healing', 'exura san', 'instant', 210, 35, 0, 0, 'no', '0;3,1;3', 0, 0),
('Wound Cleansing', 'exana mort', 'instant', 65, 30, 0, 0, 'no', '0;4,1;4', 0, 0),
('Light', 'utevo lux', 'instant', 20, 8, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Find Person', 'exiva', 'instant', 20, 8, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Magic Rope', 'exani tera', 'instant', 20, 9, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Levitate', 'exani hur', 'instant', 50, 12, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Great Light', 'utevo gran lux', 'instant', 60, 13, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Magic Shield', 'utamo vita', 'instant', 50, 14, 0, 0, 'no', '0;1,0;2,0;3,1;1,1;2,1;3', 0, 0),
('Haste', 'utani hur', 'instant', 60, 14, 0, 0, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0),
('Charge', 'utani tempo hur', 'instant', 100, 25, 0, 0, 'no', '0;4,1;4', 0, 0),
('Swift Foot', 'utamo tempo san', 'instant', 400, 55, 0, 0, 'no', '0;3,1;3', 0, 0),
('Challenge', 'exeta res', 'instant', 30, 20, 0, 0, 'no', '1;4', 0, 0),
('Strong Haste', 'utani gran hur', 'instant', 100, 20, 0, 0, 'no', '0;1,0;2,1;1,1;2', 0, 0),
('Creature Illusion', 'utevo res ina', 'instant', 100, 23, 0, 0, 'no', '0;1,0;2,1;1,1;2', 0, 0),
('Ultimate Light', 'utevo vis lux', 'instant', 140, 26, 0, 0, 'no', '0;1,0;2,1;1,1;2', 0, 0),
('Cancel Invisibility', 'exana ina', 'instant', 200, 26, 0, 0, 'no', '0;1,1;1', 0, 0),
('Invisibility', 'utana vid', 'instant', 440, 35, 0, 0, 'no', '0;1,0;2,0;3,1;1,1;2,1;3', 0, 0),
('Sharpshooter', 'utito tempo san', 'instant', 450, 60, 0, 0, 'no', '0;3,1;3', 0, 0),
('Protector', 'utamo tempo', 'instant', 200, 55, 0, 0, 'no', '0;4,1;4', 0, 0),
('Blood Rage', 'utito tempo', 'instant', 290, 60, 0, 0, 'no', '0;4,1;4', 0, 0),
('Train Party', 'utito mas sio', 'instant', 60, 32, 0, 0, 'no', '1;4', 0, 0),
('Protect Party', 'utamo mas sio', 'instant', 90, 32, 0, 0, 'no', '1;3', 0, 0),
('Heal Party', 'utura mas sio', 'instant', 120, 32, 0, 0, 'no', '1;2', 0, 0),
('Enchant Party', 'utori mas sio', 'instant', 120, 32, 0, 0, 'no', '1;1', 0, 0),
('Summon Creature', 'utevo res', 'instant', 0, 25, 0, 0, 'no', '0;1,0;2,1;1,1;2', 0, 0),
('Undead Legion', 'exana mas mort', 'instant', 500, 30, 0, 0, 'no', '0;2,1;2', 0, 0),
('Food', 'exevo pan', 'instant', 120, 14, 0, 1, 'no', '0;1,0;2,0;3,0;4,1;1,1;2,1;3,1;4', 0, 0);
 
Back
Top