Jump to content

PHP read from mysql db


gal87

Recommended Posts

Hi!

 

I really need some help, I'm very confused about it.

 

I have a mysql database called 'szakdolgozat'. In this db there's an 'xbox' table. In this table there's 4 fields: 'gameId' which is the primary key, auto_increment, int(11), 'gameTitle'(varchar(50)), 'gameGraphic'(varchar(50)), 'gameDesc'(text).

 

There is an xbox_games.php file that contains this:

<?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_xboxgames = "SELECT gameId, gameTitle, gameGraphic, gameDesc FROM xbox ORDER BY gameTitle ASC";
$xboxgames = mysql_query($query_xboxgames, $szakdolgozat) or die(mysql_error());
$row_xboxgames = mysql_fetch_assoc($xboxgames);
$totalRows_xboxgames = mysql_num_rows($xboxgames);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Konzoljátékok bemutatása</title>
<style type="text/css">
<!--
h1 {
font-size: 18px;
color: #2F9F73;
}
h2 {
font-size: 16px;
color: #28B980;
}
a:link {
text-decoration: none;
color: #48A5CC;
}
a:visited {
text-decoration: none;
color: #477AAD;
}
a:hover {
text-decoration: underline;
color: #6CB596;
}
a:active {
text-decoration: none;
}
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
color: #000;
background-image: url(images/bkgd.jpg);
background-attachment: fixed;
background-position: center top;
}

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}

/* ~~ this fixed width container surrounds the other divs ~~ */
.container {
width: 900px;
margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
}

/* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
.header {
}

/* ~~ This is the layout information. ~~

1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.

*/

.content {
padding: 10px 0;
background-image: url(images/bkgdContent.jpg);
}

/* ~~ The footer ~~ */
.footer {
padding: 10px 0;
background-color: #7295AF;
text-align: center;
}

/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
</head>

<body>

<?php include("_includes/header.php"); ?>
<h1> </h1>
<h1>
</h1>
<p>
<?php do { ?>
<a href="xbox_games_details.php?id=<?php echo $row_xboxgames['gameId']; ?>" target= "_BLANK"> <img src="_images/<?php echo $row_xboxgames['gameGraphic']; ?>" width="195" height="262" />
<?php } while ($row_xboxgames = mysql_fetch_assoc($xboxgames)); ?>
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><br />
<br />
<br />
</p>
<!-- end .content --></div>
<?php include("_includes/footer.php"); ?>
<!-- end .container --></div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html> 

 

If I see this page in the browser, it shows the covers of the xbox games, I can click any of the covers so a

http://localhost/szakdolgozat/xbox_games_details.php?id=2

is generated. The id is changing cover by cover, so I assume thats correct. What I need to do is create an xbox_games_details.php and display the detailed infos of each game.

So if the user clicks on any game covers, the xbox_games_details.php loads and shows the info page of the game. I think I need to do something with the gameId from the database.

 

Any help is muchly appreciated!

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.