The questions file I haven't included here because I haven't made any changes to that code. I did make some changes to this code though when I was adding some css to change the look of the page.
What I'd like help with is that the echos of the array aren't working to show what the users picked (a temporary part of the code so I can balanace out the stats properly). I can't understand why this is, and it's probably a case of me having been working on it all day and my brain is fried, but if someone could help me that'd be great because this is driving me mad.
<?
//here is where I include the questions file
$num_of_questions = 20;
$num_of_skills = 8;
if (isset($_POST['Go']))
{
$skills = array(0,0,0,0,0,0,0,0,0);
for ($i = 1; $i <= $num_of_questions; $i++)
{
if ($_POST['q'][$i] > count($qs[$i][answers]) || $_POST['q'][$i] < 1)
{
$errmsgs[] = 'Answer all the questions, dumbass.';
break;
}
else
{
$answer = &$_POST['q'][$i];
for ($s = 0; $s <= $num_of_skills; $s++)
{
$skills[$s] += $qs[$i][answers][$answer][skills][$s];
}
}
}
$clans = array(
'1' => $skills[clan1],
'2' => $skills[clan2],
'3' => $skills[clan3],
'4' => $skills[clan4],
);
$clan1 = $skills[clan1];
$clan2 = $skills[clan2];
$clan3 = $skills[clan3];
$clan4 = $skills[clan4];
$highest= key(array_fill_keys(array_keys($clans, max($clans)), max($clans)));
$memory = $skills[memory];
$physical = $skills[physical];
$reflexes = $skills[reflexes];
$wethic = $skills[wethic];
$charisma = $skills[charisma];
echo "<br>clan1: ".$clan1;
echo "<br>clan2: ".$clan2;
echo "<br>clan3: ".$clan3;
echo "<br>clan4: ".$clan4;
echo "<br>Clan: ".$highest;
echo "<br>memory: ".$memory;
echo "<br>physical: ".$physical;
echo "<br>reflexes: ".$reflexes;
echo "<br>wethic: ".$wethic;
echo "<br>charisma: ".$charisma;
}
echo '<form method="POST" action="startup.php">';
echo '<table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr>
<td colspan="2" style="text-align: center;"><strong>Answer these</strong></td>
</tr>';
for ($i = 1; $i <= $num_of_questions; $i++)
{
echo '<tr>
<td colspan="2"><strong>'.$qs[$i][answer].'</strong></td>
</tr>';
for ($q = 1; $q <= $qs[$i][num]; $q++)
{
echo '<tr>
<td>'.$qs[$i][answers][$q][0].'</td>
<td><input name="q['.$i.']" value="'.$q.'" type="radio" /></td>
</tr>
<tr>
<td><hr></td>
</tr>';
}
}
echo '</table>';
echo '<input type="submit" value="Go" name="submit"></form>';
?>

New Topic/Question
Reply




MultiQuote





|