Jump to content

SELECT lowest and highest values from int in database?


corrupshun

Recommended Posts

Hello, I recently created a game website but am not fully satisfied with it.

So basically I use GET to choose which game will display, and to make sure people don't put in stupid crap i used the range() function

The problem is I REALLY do not want to edit the game page each time i add a new game.

The code is below, and as you can see there is a range(1,4)

--

MY QUESTION:

Is there a way I can SELECT the ID from my database and get the lowest and highest values, set them as variables, and then put them in the range function?

This would perfect my game page! :)

 

<?php
include("inc/template.php");
echo "$headers";
$nothing = "";
$list = range(1,4);
if(!isset($_GET['gameid'])) {
include("inc/defaultgame.php");
}
elseif($_GET['gameid'] == $nothing){
include("inc/defaultgame.php");
}
elseif(in_array($_GET['gameid'], $list) === false) {
echo "Invalid GameID";
include("inc/defaultgame.php");
}
else {
$con = mysql_connect("localhost","root","");
mysql_select_db("Corrupshun", $con);
$query = mysql_query("SELECT Title, Side, Path FROM Games WHERE id = $_GET[gameid]");
while($row = mysql_fetch_assoc($query)) {
$gametitle = $row['Title'];
$gameside = $row['Side'];
$gamepath = $row['Path'];
}
}
?>
<title><?php echo "$title[game] $gametitle"; ?></title>
</head>
<body>
<?php echo "$banner"; ?>
<?php echo "$pagediv"; ?>
<?php echo "$nav"; ?>
<?php echo "$bodydiv"; ?>
<div class="h"><?php echo "$gametitle"; ?></div>
<div class="s"><?php echo "$gameside"; ?></div>
<?php echo "$paramstart"; ?>
<?php echo "$gamepath"; ?>
<?php echo "$paramend"; ?>
<?php echo "$divend"; ?><!--body-->
<?php echo "$news"; ?><!--news-->
<?php echo "$divend"; ?><!--page-->
<?php echo "$copyright"; ?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

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