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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.