Jump to content

[SOLVED] beginner dynamic page, difficulty passing variables?


imstumped

Recommended Posts

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  :)

 

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');

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.