little help pls
Posted: Sat Aug 07, 2004 5:01 pm
Hello, im done writing a program now i just need to find a way to enter the data through a form. ive been working on it but i just cant figure out whats wrong.
The first drop down menu works then when i submit it it brings me to another form which displays the data then i click the 'edit game' button i want it to edit the info, its just that the second form dosnt enter the info, any help?
Code: Select all
<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("games",$db);
if (empty($gameName)) {
#put query inside the loop so it doesnt get run if the form has been submitted
$result = mysql_query("SELECT * FROM gamesinfo ORDER BY gameName",$db);
echo "<h1>Edit Game</h1>";
echo "<form method="post">";
echo "<select name="gameName">";
while($row = mysql_fetch_assoc($result)) {
extract($row);
echo "<option value="$gameName">$gameName</option>\n";
}
echo "</select>";
echo "<input type="submit" value="Edit Game">";
}
else
{
$result = mysql_query("SELECT * FROM gamesinfo WHERE gameName = '".$_POST['gameName']."' LIMIT 1");
$sql = mysql_query("UPDATE gamesinfo SET gameName = '$_POST[gamename]' AND minPlayer = '$_POST[minplayer]' AND maxPlayer = '$_POST[maxplayer]' AND prvPrice = '$_POST[prvprice]' AND pubPrice = '$_POST[pubprice]' AND WHERE id = '$id'");
$result = mysql_fetch_assoc($result);
#the game data is now held in the $result variable
$id = $result[id];
$gamename = $result[gameName];
$minplayer = $result[minPlayer];
$maxplayer = $result[maxPlayer];
$prvprice = $result[prvPrice];
$pubprice = $result[pubPrice];
echo "<h1>Below are the record details</h1><br><br>";
echo "<form method="post">";
echo "
<table border="0"><tr>
<td>ID:</td><td><input name="$id" type="text" value="$id"> </td></tr>
<td>Game Name:</td><td><input name="$gamename" type="text" value="$gamename"> </td></tr>
<tr><td>Minimum Players:</td><td><input name="$minplayer" type="text" value="$minplayer"></td></tr>
<tr><td>Miximum Players:</td><td><input name="$maxplayer" type="text" value="$maxplayer"></td></tr>
<tr><td>Private Price:</td><td><input name="$prvprice" type="text" value="$prvprice"></td></tr>
<tr><td>Public Price:</td><td><input name="$pubPrice" type="text" value="$pubprice"></td></tr>
</tr></table> ";
echo "<br><br><input type="submit" value="Edit Game">";
echo "<input type="button" onClick="history.back()" value="Back">";
echo "</form>";
}
?>