Here is my code
Code: Select all
<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("games",$db);
$result = mysql_query("SELECT * FROM gamesinfo ORDER BY gameName",$db);
if (empty($gameName)) {
echo "<form>";
//Function Chooses the game
print "Select your game: ";
echo "<select name="gameName">";
while($row = mysql_fetch_assoc($result))
{
extract($row);
echo "<option value="$gameName">$gameName</option>\n";
}
echo "</select>";
print "<br><br>";
//END
//Function Player Ammount yields the ammount of players to chose from
print "Select the number of players: ";
$output = '<select name="playerAmmount">';
for($i = $minPlayer; $i <= $maxPlayer; $i += 2) {
$output .= '<option value="'.$i.'">'.$i.'</option>';
}
$output .= '</select>';
echo $output;
print "<br><br>";
//END
//Function determines weather or not the server is to be public or private
print "Choose weather your server is public or private, private servers require passwords to join:";
print "<br>
<select name="pubOrPrv">
<option value="$pubPrice">Public Server
</option>
<option value="$prvPrice">Private Server
</option>
</select>";
print "<br><br>";
//END
//This function displays the optional Team Speak server
print "Optional: Team Speak Voice Server:
<br>
Chose the server ammount: ";
$output = '<select name="teamSpeak">';
$output .= '<option value="No Team Speak Server">No</option>';
for($i = 10; $i <= 50; $i += 2) {
$output .= '<option value="'.$i.' Person Team Speak Server">'.$i.'</option>';
}
$output .= '</select>';
echo $output;
print "<br><br>";
//END
echo "<input type="submit" value="Get Price">";
echo "<input type="reset" value="Reset Form">
</form>";
} else {
echo "<h1>Below are your order details</h1><br><br>";
echo "
Game Name: $gameName
<br><br>
Ammount of Players: $playerAmmount
<br><br>
Public/Private Price: $pubOrPrv
<br><br>
$teamSpeak
<br><br>";
echo "Your Team Speak Voice Server Cost: $";
echo $teamSpeak * .40;
$tsPrc = $teamSpeak * .40;
echo "<br>Your Game Server Cost: \$";
echo $playerAmmount * $pubOrPrv;
$gamePrc = $playerAmmount * $pubOrPrv;
echo "
<br>
Your final price is: \$";
echo $gamePrc + $tsPrc;
echo "<br><br><input type="submit" value="Submit Request">";
echo "<input type="button" onClick="history.back()" value="Back">";
}
?>In my database called games, there is a table called gamesinfo, in there right now there are 2 rows
0 | Americas Army | 3.00 | 2.50 | 8 | 64
1 | Counter-Strike | 2.00 | 2.50 | 8 | 64
When I select Americas Army I want it to just deal with row 0 so when it does the math it works with the values 3.00 and 2.50 like-wise when I choose Counter-Strike i want it do deal with values 2.00 and 2.50 dollars. Right now it just deals with the last row, in this case Counter-Strike so in both instances it deals with 2.00 and 2.50 no matter what game is selected.
feyd | THIS IS NOT A TUTORIAL. Moved to PHP - Code