gal87 Posted March 23, 2011 Share Posted March 23, 2011 Hi there! I want to create a website about consoles & console games. Right now I'm at the very early stages of it, you can see it on this address: http://www.gal87.tarhely.biz/szakdolgozat As you can see, on the site there's 5 menu point: Kezdőlap (Home), Xbox 360, Playstation 3, Wii, Közösség (Community/Forum). Each console menu contains a drop down menu, "A konzolról" = 'About console' and "Játékok" = 'Games'. I've already created a database for the xbox games that contains the gameid (primary key), gameTitle, gameGraphic, gameDescription. First of all I need to list the Xbox games by title or by the graphics (cover of the games). Then if somebody clicks any of the title/covers then it show the detailed info of the game on a new page or something like that. I hope you understand, what I mean, guys. Is is possible to do this? /*Sorry for my grammar, I'm from Hungary.*/ Thanks for ANY help/advice/suggestion in advance! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 23, 2011 Share Posted March 23, 2011 Of course it's possible. Where are you stuck, exactly? Quote Link to comment Share on other sites More sharing options...
gal87 Posted March 24, 2011 Author Share Posted March 24, 2011 Well, I know how to connect to the mysql database. Here's my code: <?php require_once('Connections/szakdolgozat.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_szakdolgozat, $szakdolgozat); $query_rs_xboxgames = "SELECT gameTitle, gameGraphic, gameDesc FROM xbox ORDER BY gameId ASC"; $rs_xboxgames = mysql_query($query_rs_xboxgames, $szakdolgozat) or die(mysql_error()); $row_rs_xboxgames = mysql_fetch_assoc($rs_xboxgames); $totalRows_rs_xboxgames = mysql_num_rows($rs_xboxgames); ?> And in the body part: <?php include("_includes/header.php"); ?> <h1> </h1> <h2><?php echo $row_rs_xboxgames['gameTitle']; ?></h2> <p><img src="_images/<?php echo $row_rs_xboxgames['gameGraphic']; ?>" width="195" height="262" /></p> <p><?php echo $row_rs_xboxgames['gameDesc']; ?></p> With this method I can display a game's name, cover, and description from the database. But I don't know how to display in one page only the cover/title of the games, then on an other page the full detailed infos (with description) of the game. I'm really confused. I'm using Adobe Dreamweaver CS5, the whole code above was made by that program. Quote Link to comment Share on other sites More sharing options...
litebearer Posted March 24, 2011 Share Posted March 24, 2011 1. in your query also include getting the game id, you will need that to know which game to display on your 'second page'. 2. In the body part <?php include("_includes/header.php"); ?> <h1> </h1> <h2><?php echo $row_rs_xboxgames['gameTitle']; ?></h2> <p><a href="details.php?id=<?PHP echo $GAME_ID; ?>" target= "_BLANK"><img src="_images/<?php echo $row_rs_xboxgames['gameGraphic']; ?>" width="195" height="262" /></a></p> <p><?php echo $row_rs_xboxgames['gameDesc']; ?></p> 3. In the details.php file <?PHP $id = $_GET['id']; /* then use that $id to query the db for the details of the game and display them */ Make sense? Quote Link to comment Share on other sites More sharing options...
gal87 Posted March 24, 2011 Author Share Posted March 24, 2011 Thank you very much for your help! I've made the changes in the body part, that works like a charm. But I don't really get the include.php part. Quote Link to comment Share on other sites More sharing options...
litebearer Posted March 24, 2011 Share Posted March 24, 2011 My pleasure. Not sure what you mean by... But I don't really get the include.php part. Quote Link to comment Share on other sites More sharing options...
gal87 Posted March 24, 2011 Author Share Posted March 24, 2011 /* then use that $id to query the db for the details of the game and display them */ Now, if I click any xbox games cover, it doesn't load the details, and the link looks like this: http://localhost/szakdolgozat/xbox_games_details.php?id= I assume the problem is, that the number is missing after the "id=". So long story short, I don't know how to "use the $id to query the db". Sorry, if this is a lame question, but I'm just started to learn to create dynamic websites. Quote Link to comment Share on other sites More sharing options...
litebearer Posted March 24, 2011 Share Posted March 24, 2011 1. show us you most recent code (complete sans username, password). 2. is the name of your details file - xbox_games_details.php ? Quote Link to comment Share on other sites More sharing options...
gal87 Posted March 24, 2011 Author Share Posted March 24, 2011 Yes, the details file is xbox_games_details.php. Code from that details file: <?php require_once('Connections/szakdolgozat.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_szakdolgozat, $szakdolgozat); $query_Recordset1 = "SELECT gameId, gameTitle, gameGraphic, gameDesc FROM xbox"; $Recordset1 = mysql_query($query_Recordset1, $szakdolgozat) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> Then i put the <?PHP $id = $_GET['id']; in the body part. 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.