imstumped Posted October 15, 2008 Share Posted October 15, 2008 I am trying to create a very simple playgame.php dynamically from my tiny database (gamefile, gametitle, indexer) . I used a simple tutorial i found to create a nifty menu via generateMenu(). It creates a short text menu (title1, title2, etc..) that targets: www.domain.com/playgame.php?p=sample%20game%20title (the %20 are auto inserted - anyway to replace??) When they click the link, how can I play the correct ['gamefile'] that corresponds to the ['gametitle'] in the url - via the makeGameHtml()? <?php include ('config.php'); $load = mysql_query("SELECT * FROM games"); //Add in the format of: $menu['page name'] = 'Page Title'; while ($game = mysql_fetch_array($load)){ $menu[$game['gametitle']]= $game['gametitle']; } $title='Home'; //Default title function generateMenu() { global $menu,$default,$title; echo ' <ul>'; $p = isset($_GET['p']) ? $_GET['p'] : $default; foreach ($menu as $link=>$item) { echo '<li><a href="?p='.$link.'">'.$item.'</a></li>'; } echo '</ul>'; } function makeGameHtml($file){ echo "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" > <param name=\"movie\" value=\"games/{$file}\" /> <param name=\"quality\" value=\"high\" /> <embed src=\"games/{$file}\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" ></embed> </object>" ; } //somehow call my makeGameHtml() correctly to play my game $file ?> I don't have this function called in the code atm because I couldn't get it to work. I felt like I was close, but, no matter how I tried to set variables, it kept loading a blank file name instead of the correct gamefile. I also tried using the auto increment ['indexer'] in place of ['gametitle']. Thank you for reading Quote Link to comment Share on other sites More sharing options...
aeonsky Posted October 15, 2008 Share Posted October 15, 2008 Think this should be good... preg_replace("/%20/", " ", $_REQUEST['p']); Quote Link to comment Share on other sites More sharing options...
rocoso Posted October 15, 2008 Share Posted October 15, 2008 Mabey your fuction should be like this? function makeGameHtml($file){ $myreturn = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" > <param name=\"movie\" value=\"games/$file\" /> <param name=\"quality\" value=\"high\" /> <embed src=\"games/$file\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" ></embed> </object>"; return $myreturn; } then just print makeGameHtml('flash.swf'); Quote Link to comment Share on other sites More sharing options...
imstumped Posted October 15, 2008 Author Share Posted October 15, 2008 Hi Rocoso, makeGameHtml() seems to come out fine in the html code. I'm having trouble getting the correct flashgame to play, though. I want it to automatically pass the gameFile that correctly matches the gameTitle link they clicked on. Quote Link to comment Share on other sites More sharing options...
imstumped Posted October 15, 2008 Author Share Posted October 15, 2008 Figured it out. $link=$_GET[p] from URL SELECT gamefile FROM games WHERE gametitle='".$link."'" Got the gamefile to play with my function! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.