Jump to content

[SOLVED] mysql select error,


blueman378

Recommended Posts

<?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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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];
    }

?>

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.