I've been working on a mafia game, in PHP. And I'm on to the Crimes page. I want it to be done by the database, so I can add crimes etc whenever. I've managed to make it echo the Crime names and payouts to the page, but I'm having trouble when pressing the commit button.
I hope this makes sense.
$getCrimes = mysql_query("SELECT * FROM crimes ORDER BY crimeid ASC");
$thepost = $_POST['crimeid'];
if ($_POST['commit']) {
$crimethingy = $_POST['crimeid'];
$getArray = mysql_fetch_array(mysql_query("SELECT * FROM crimes WHERE crimeid = '$thepost'"));
$theID = $getArray['crimeid'];
$theName = $getArray['crimename'];
if ($crimethingy > 0) {
echo $theName;
}
}
while ($crimeRows = mysql_fetch_array($getCrimes)) {
$crime_id = $_POST['crimeid'];
$crimeID = $crimeRows['crimeid'];
$crimeName = $crimeRows['crimename'];
$lowestPayout = $crimeRows['payoutlow'];
$highestPayout = $crimeRows['payouthigh'];
echo
"
<table cellpadding='2' cellspacing='1' width='75%' class='content-cell' align='center' style='margin-top: 5px; margin-bottom: 5px;'>
<tr><td class='header'>Avaliability</td></tr>
<tr><td class='content' style='height: 50px;'>
<i style='font-size: 13px;'><center>$crimeName</center></i>
<br>
<i style='font-size: 11px;'><center>£$lowestPayout - £$highestPayout</center></i>
</td></tr>
<tr><td class='header'><input type='hidden' name='crimeid' value='$crimeID'>
<input type='submit' name='commit' value='Commit' style='width: 100%' class='submit'></td></tr>
</table>
";
}
This is my code. The top part only echos out one of the crime names, not the other.