stuff

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

stuff

Post by SidewinderX »

Hello, ive been working on a script and now its ready to get information from a data base. I created a database called games and a table called gamesinfo and rows called gameName, pubPrice, prvPrice, minPlayer and maxPlayer.

Code: Select all

<?php
$db = mysql_connect("localhost", "", ""); 
mysql_select_db("games",$db); 
$result = mysql_query("SELECT * FROM gamesinfo",$db);

if (empty($gameName)) {

//Function Chooses the game
print "Select your game: ";
echo "<select name="gameName">";
while($row = mysql_fetch_assoc($result)) 
{ 
  extract($row); 
$gamename = $row['gameName'];
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 = 8; $i <= 64; $i += 2) {  //replace 8 and 64 with variables from my database
$output .= '<option value="'.$i.'">'.$i.'</option>'; 
} 
$output .= '</select>'; 
echo $output; 
print "<br><br>";
//END

//This displays public/private
echo "Choose weather your server is public or private, private servers require passwords to join:";
echo "<br>
<select name="pubOrPrv">
<option value="$pubPrice">Public Server
</option>
<option value="$prvPrice">Private Server
</option>
</select>";
echo "<br><br>";
//END

//This 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 {
I have some other stuff in here...but I dont want to make the post too big and plus it irrelivent. I would of taken it out but im sure the if..else thing has some kind of inpact.
} 
?>
Ive been fooling around with it and with some help from a friend, I was actually able to get the info from the data base in the first drop down menu...its probabley messy but hey what do you want 8)

Now, the one that starts
//Function Player Ammount yields the ammount of players to chose from
I want "8" to be replaced with minPlayers from my database, and 64 be replaced with maxPlayers from my data base.

All help is appreciated,
Thankyou.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

str_replace()
Post Reply