corrupshun Posted November 26, 2009 Share Posted November 26, 2009 So I've decided to jump into the realm of flash game websites Now what I've realized on most sites is one file called something like games.php When you click the link to the game you want to play it would be like games.php?gameid=293 And this would have the same template as all the other games have but loads a different title and flash game. I know that the ?gameid=293 is using php GET but how would I implement this? Would it take information from a database? I know I could make a VERY long conditional list but that's obviously the stupid way Is this possible without a database? If possible please give some code.. Thanks LOTS! -Aus Link to comment https://forums.phpfreaks.com/topic/182975-easy-question-for-php-pros/ Share on other sites More sharing options...
Goldeneye Posted November 26, 2009 Share Posted November 26, 2009 This sort of thing is not possible without a database. Whether it's a flat-file database or a Structured-Query-Language Database, you need something to store the information for the games in. Also $_GET['id'] would be the I.D. of the row of the corresponding game in the database. So say you have an database table called `flashgames`: `id` `title` `path` 1 Game1 /games/1.swf 2 Game 2 /games/foo.swf 3 Game 3 /games/bar.swf So in your table, `id` would be the automatically generated I.D. number of the row, `title` would be the title of the game, and `path` would be the file-path to the game-file (flash games are usually in .swf). So then your script might look like this: <?php $id = $_GET['id']; $query = mysql_query("SELECT `title`, `path` FROM `flashgames` WHERE `id`=$id"); $row = mysql_fetch_assoc($query); echo $row['title']; echo '<br />'.$row['path']; ?> So, with those dummy code snippets, if $_GET['id'] = 2, you'd see "Game2" followed by "/games/foo.swf" on the line below "Game2" Link to comment https://forums.phpfreaks.com/topic/182975-easy-question-for-php-pros/#findComment-965785 Share on other sites More sharing options...
corrupshun Posted November 26, 2009 Author Share Posted November 26, 2009 You sir, are a baller! thanks! Link to comment https://forums.phpfreaks.com/topic/182975-easy-question-for-php-pros/#findComment-965792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.