andrew95434
Banned User
i have a spell list on my modern aac website, where you can search spells by vocation, but i have 3 problems with it: (php code of the page at the end of the thread)
1. Where it have to say "no", in PACC column (if the spell is for premium or not), it says "0yes".
2. In every spell, at the vocation column, is included the vocation "None", so in every row are 2 vocations (the real and "None"), it makes the rows higher and the "None" vocation is unnecessary.
3. The search bar doesn't work, because when i select any vocation, it gives me all the vocations, as if I hadn't pressed anything. I think that if I fix the error number "2" this error would be fixed too, but I'm not sure.
The PHP code of the Spell Page:
1. Where it have to say "no", in PACC column (if the spell is for premium or not), it says "0yes".
2. In every spell, at the vocation column, is included the vocation "None", so in every row are 2 vocations (the real and "None"), it makes the rows higher and the "None" vocation is unnecessary.
3. The search bar doesn't work, because when i select any vocation, it gives me all the vocations, as if I hadn't pressed anything. I think that if I fix the error number "2" this error would be fixed too, but I'm not sure.
The PHP code of the Spell Page:
<?php
echo '<div class="message"><div class="title">Spell Search</div></div>';
$ots = POT::getInstance();
$ots->connect(POT:B_MYSQL, connection());
$SQL = $ots->getDBHandle();
$vocations = array('None', 'Sorcerer', 'Druid', 'Paladin', 'Knight', 'Master Sorcerer', 'Elder Druid', 'Royal Paladin', 'Elite Knight');
echo '<FORM ACTION="" METHOD=post>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR='.$config['site']['darkborder'].'><td>Only for vocation: <SELECT NAME="vocation_id">';
foreach($vocations as $id => $vocation)
echo '<option value="'.$id.'">'.$vocation.'</option>';
echo '</SELECT> <INPUT TYPE=submit NAME="Submit" ALT="Submit" ></td><TR>
</TABLE></FORM>
<table border="1" cellspacing="0" cellpadding="4" width="100%">
<tr class="bar">
<td><strong>Name</strong></td>
<td><strong>Sentence</strong></td>
<td><strong>Type</strong></td>
<td><strong>Mana</strong></td>
<td><strong>Level</strong></td>
<td><strong>Soul</strong></td>
<td><strong>PACC</strong></td>
<td><strong>Vocations</strong></td>';
$spells = $SQL->query('SELECT * FROM z_spells WHERE hide_spell = 0 ORDER BY name');
foreach($spells as $spell) {
$spell_vocations = explode(';', $spell['vocations']);
$vocs = '';
foreach($spell_vocations as $allowed)
$vocs .= $vocations[$allowed].'<br />';
if($_POST['vocation_id']) {
$voc = $_POST['vocation_id'];
$promoted = $voc > 4 ? $voc - 4 : false;
if(in_array($voc, $spell_vocations) || in_array($promoted, $spell_vocations))
echo '<tr class="over"><td>'.$spell['name'].'</td><td>'.$spell['spell'].'</td><td>'.$spell['spell_type']. ($spell['conj_count'] ? '('.$spell['conj_count'].')' : '').'</td><td>'.$spell['mana'].'</td><td>'.$spell['lvl'].'</td><td>'.$spell['soul'].'</td><td>'.($spell['pacc'] ? 'yes' : 'no' ).'</td><td>'.$vocs.'</td></tr>';
}
else
echo '<tr class="over"><td>'.$spell['name'].'</td><td>'.$spell['spell'].'</td><td>'.$spell['spell_type'].'</td><td>'.$spell['mana'].'</td><td>'.$spell['lvl'].'</td><td>'.$spell['soul'].'</td><td>'.($spell['pacc'] ? 'yes' : 'no' ).'</td><td>'.$vocs.'</td></tr>';
}
echo "</table>";
?>
<style type="text/css">
tr.over:hover {
background-color: #FAFAD2;
}
.link {text-decoration: none;font-weight:bold;color:black;}
.more { display: none;}
</style>