Je monstername is nu altijd met value 1 dat zag je wel ?
Wat jij wilt bereiken is dat de input radio op elke waarde een andere naam heeft.
P.S. leer wel van je foutafhandelingen in de code, ik doe dit niet voor me plezier maar om jou op weg te helpen, overigens is niet alles 100% veilig
<?php
// Check if session is already running or not
if (!session_id()) session_start();
// Include connection/header
include_once "connect.php";
include_once "up_html.php";
// Check for session "player"
if (isset($_SESSION['player']))
{
//Find player within session
$playersess = mysql_real_escape_string($_SESSION['player']);
$sql_users = "SELECT * FROM km_users WHERE playername = '" . $playersess . "'";
// Check if query "km_users" could run
if ($result_users = mysql_query( $sql_users ))
{
$player = mysql_fetch_array($result_users); ?>
<table class="maintable">
<tr class="headline"><td><center>Select Monster to Slay</center></td></tr>
<tr class="mainrow"><td>
<form method="post">
<?php
$sql_monsters = "SELECT * FROM km_monsters ORDER BY skill ASC";
// Check if query "km_monsters" could run
if ($result_monsters = mysql_query( $sql_monsters ))
{
// While loop the results
while ($monsters = mysql_fetch_array($result_monsters))
{
$totalskill = $player['skillpts'] + $monsters['stats'];
$chance = ($player['skillpts'] / $totalskull * 100);
$chance = round($chance, 0, PHP_ROUND_HALF_UP); ?>
<input type="radio" name="monstername" value="<?php echo $monsters['name']; ?>" checked><b><?php echo $monster['name']; ?></b><br>
<p><?php echo $chance; ?> chance, reward: <?php echo $monster['goldworth']; ?> gold</p><hr>
<?php
}
}
else {
// Query could not run
echo "Error running query, contact the administrator.";
}
?>
<br>
<input type="submit" name="submit" value="Hunt Animal">
</form>
</td></tr>
</table>
<?php
// Run form submit
if (isset($_POST['submit']))
{
// Player has no more turns
if ($player['numturns'] < 1) {
echo 'You need at least 1 turn to kill a monster, please go back to <a href="index.php">Main</a>';
}
else {
// Turns left, run the page
$monstername = mysql_real_escape_string($_POST['monstername']);
$sql_monster = "SELECT * FROM km_monsters WHERE name = '" . $monstername . "'";
// Check if query "km_monsters" could run
if ($result_monsters = mysql_query( $sql_monsters ))
{
$monsters = mysql_fetch_array($result_monsters);
// Calculate monsters
$totalskill = $player['skillpts'] + $monsters['skill'];
$randnumber = rand(1, $totalskill);
$chance = ($player['skillpts'] / $totalskill * 100);
if ($randnumber <= $player['skillpts'])
{
$gained = $monsters['pointsifkilled'];
$gold = $monster['goldworth'];
$sql_users = "UPDATE km_users SET skillpts = skillpts + '" . $gained . "', gold = gold + '" . $gold . "' WHERE playername = '" . $playersess . "'";
if ($result = mysql_query( $sql_users )) { ?>
<center><img src="images/knight.gif"></center>
You slay the <?php echo $monster['name']; ?> is glorius combat and gained <?php echo $gained; ?> skillpts
<center><a href="index.php">Kill more monsters</a></center>
<?php
}
else {
// Could not run query
echo "Error running query, please contact the administrator.";
}
}
else {
// Lost battle from monster ?>
<center><img src="images/defeat.gif"></center>
<?php echo $chance; ?> The <?php echo $monster['name']; ?> laughs as you run away from the battle like a chicken<br><br>
<a href="index.php">Kill more monsters</a>
<?php
}
}
else {
// Could not run query
echo "Error running query, please contact the administrator";
}
}
}
}
else {
// Could not run query
echo "Error running query, please contact the administrator";
}
}
else {
// Player is not logged in
echo 'You are not logged in, please <a href="login.php">Login</a>';
}
// Include footer
include_once "down_html.php";
Toon Meer