Just a brief intro
My Aim: It is to read data from mysql table, from 2 fields in particular called 'esrb' and 'genre'. I have managed to output on an edit page the values of 'esrb' and 'genre'. The 2 fields output to a set of radio buttons.
So ESRB values could be:
Not Rated
Everyone
Teen
Mature
and Genre
Fighting
War
Action
Adventure
These are radio buttons and whatver is in the field in the mysql row, by default the correct radio button is checked. Now if i change this radio button to something else like from Everyone to Teen or from War to Acrtion, i CANT seem to get it to update the values in the mysql table.
Here is the code editgame.php
Code: Select all
<?php
include('db.php');
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM ccms_gameindex WHERE id = $id");
$row = mysql_fetch_array($result);
$genre=$row['genre'];
$esrb=$row['esrb'];
switch($genre)
{
case "Shooter": $checkshooter = "checked"; break;
case "Racer": $checkracer = "checked"; break;
case "Pinball": $checkpinball = "checked"; break;
case "Puzzle": $checkpuzzle = "checked"; break;
case "Strategy": $checkstrategy = "checked"; break;
case "Action": $checkaction = "checked"; break;
case "Boardgame": $checkboardgame = "checked"; break;
case "Fighting": $checkfighting = "checked"; break;
case "Sim": $checksim = "checked"; break;
case "RPG": $checkrpg = "checked"; break;
case "Sports": $checksports = "checked"; break;
case "Adventure": $checkadventure = "checked"; break;
case "War": $checkwar = "checked"; break;
}
switch($esrb)
{
case "Not Yet Rated": $checknotyetrated = "checked"; break;
case "Early Childhood": $checkearlychildhood = "checked"; break;
case "Everyone": $checkeveryone = "checked"; break;
case "Everyone 10+": $checkeveryone10 = "checked"; break;
case "Teen": $checkteen = "checked"; break;
case "Mature 17+": $checkmature17 = "checked"; break;
case "Adults Only 18+": $checkadultsonly = "checked"; break;
}
?>
Game Name: <?php echo $row['title']; ?></br>
<form action="subgame.php" method="post">
<table><tr><td>
Genre: <input type="text" name="genre" value="<?php echo $row['genre']?>" /></br>
</td><td>
ESRB: <input type="text" name="esrb" value="<?php echo $row['esrb']?>" /></br>
</td></tr>
<tr><td>
<input type="radio" name="genre" Value="Shooter" <?=$checkshooter?> > Shooter </br>
<input type="radio" name="genre" Value="Racer" <?=$checkracer?>> Racer</br>
<input type="radio" name="genre" Value="Pinball" <?=$checkpinball?>> Pinball</br>
<input type="radio" name="genre" Value="Puzzle" <?=$checkpuzzle?> > Puzzle</br>
<input type="radio" name="genre" Value="Strategy" <?=$checkstrategy?> > Strategy</br>
<input type="radio" name="genre" Value="Action" <?=$checkaction?> > Action</br>
<input type="radio" name="genre" Value="Boardgame" <?=$checkboardgame?>> Boardgame</br>
<input type="radio" name="genre" Value="Fighting" <?=$checkfighting?>> Fighting</br>
<input type="radio" name="genre" Value="Sim" <?=$checksim?> > Sim</br>
<input type="radio" name="genre" Value="RPG" <?=$checkrpg?> > RPG</br>
<input type="radio" name="genre" Value="Sports" <?=$checksports?> > Sports</br>
<input type="radio" name="genre" Value="Adventure" <?=$checkadventure?>> Adventure</br>
<input type="radio" name="genre" Value="War" <?=$checkwar?>> War</br>
</td>
<td>
<input type="radio" name="esrb" Value="Not Yet Rated" <?=$checknotyetrated?> > Not Yet Rated</br>
<input type="radio" name="esrb" Value="Early Childhood" <?=$checkearlychildhood?>> Early Childhood</br>
<input type="radio" name="esrb" Value="Everyone" <?=$checkeveryone?>> Everyone</br>
<input type="radio" name="esrb" Value="Everyone 10+" <?=$checkeveryone10?>> Everyone 10+</br>
<input type="radio" name="esrb" Value="Teen" <?=$checkteen?> > Teen</br>
<input type="radio" name="esrb" Value="Mature 17+" <?=$checkmature17?> > Mature 17+</br>
<input type="radio" name="esrb" Value="Adults Only 18+" <?=$checkadultsonly?> > Adults Only 18+</br>
</td></tr></table>
<input type="submit" />
</form>
Code: Select all
<?php include('db.php'); ?>
<?php
$id=$_POST['id'];
$esrb=$_POST['esrb'];
$genre=$_POST['genre'];
?>
<?php
$sql="UPDATE ccms_gameindex SET esrb='$esrb', genre='$genre', WHERE id ='$id'"
mysql_query($sql);
echo "Record Updated";
mysql_close();
?>