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>

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.