blueman378 Posted December 3, 2007 Author Share Posted December 3, 2007 ok thanks mate, one last thing, how would i echo eg the game name Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 3, 2007 Share Posted December 3, 2007 Where do you want it echo'd? PhREEEk Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 3, 2007 Author Share Posted December 3, 2007 <?php include("include/session.php"); ?><html> <head></head> <body> <?php $game = $_GET['game']; function GetInfo($game){ global $database; $q = "SELECT * FROM " . Games . " WHERE gName = '$game' ORDER BY `gName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if( $num_rows == 0 ){ return 'Database table empty'; } /* Display table contents */ $content = "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\"> <tr> <td><b>Game Name</b></td> <td><b>Description</b></td> <td><b>Swf File</b></td> <td><b>Thumb File</b></td> </tr> "; while( $row = mysql_fetch_assoc($result) ) { $content .= "<tr> <td>$row[gName]</td> <td>$row[gDescription]</td> <td>$row[gSwfFile]</td> <td>$row[gThumb]</td> </tr> "; } $content .= "</table><br>\n"; return $content; } // You can echo GetInfo($game); ?> <br> <h1>GAME NAME HERE</h1> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com /pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="400" height="300" id="movie" align="center"> <param name="movie" value="games_ins/SWF FILE HERE"> <embed src="games_ins/SWF FILE HERE" quality="high" width="400" height="300" name="movie" align="center" type="application/x-shockwave-flash" plug inspage="http://www.macromedia.com/go/getflashplayer"> </object> DESCRIPTION HERE </body></html> its the stuff it CAPS and while ur here, if i decide to use a form i just change it to POST right? Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 3, 2007 Share Posted December 3, 2007 Currently, $game is available everywhere in the script... even in the function now. You can echo it anytime you want. If you create a form, you can use method="get" if you want, or post, doesn't matter for small data like this. Just change GET to POST in the receiving script if you go with that. PhREEEk Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 3, 2007 Author Share Posted December 3, 2007 ok well i can use that for the game name, but how do i go about the description ect? cause it cant seem to access them Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 3, 2007 Share Posted December 3, 2007 Well, planning ahead is paramount to efficient programming... I have no idea what your 'bigger picture' is. If you want to do more with the information pulled out of the database, it would be best to rewrite the function so that it only creates an array of data. Then you will have the array available at all times... so that means we would ditch the $content stuff and instead populate an array with the data. We would format the data for screen outside of the function. PhREEEk Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 4, 2007 Author Share Posted December 4, 2007 um, yeah the page originally was just so i could get an idea of how it works, but um could u give me an example of what u mean? thanks, matt uve been a great help Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 4, 2007 Author Share Posted December 4, 2007 lol well that was simple, i managed it myself <?php include("include/session.php"); $game = $_GET['game']; global $database; $q = "SELECT * FROM " . Games . " WHERE gName = '$game' ORDER BY `gName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if( $num_rows == 0 ){ return 'Game Not Found!'; } while( $row = mysql_fetch_assoc($result) ) { echo $row[gName]; echo $row[gDescription]; echo $row[gSwfFile]; echo $row[gThumb]; } ?> 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.