corrupshun Posted December 5, 2009 Share Posted December 5, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/184098-select-lowest-and-highest-values-from-int-in-database/ Share on other sites More sharing options...
fenway Posted December 5, 2009 Share Posted December 5, 2009 You mean with MIN() and mAX()? Quote Link to comment https://forums.phpfreaks.com/topic/184098-select-lowest-and-highest-values-from-int-in-database/#findComment-971929 Share on other sites More sharing options...
Zane Posted December 5, 2009 Share Posted December 5, 2009 use MAX() for the highest value use MIN() for the lowest value example SELECT MAX(id) as latestGame, MIN(id) as firstGame FROM games Quote Link to comment https://forums.phpfreaks.com/topic/184098-select-lowest-and-highest-values-from-int-in-database/#findComment-971932 Share on other sites More sharing options...
corrupshun Posted December 5, 2009 Author Share Posted December 5, 2009 jeez, it's that easy..wow i suck Quote Link to comment https://forums.phpfreaks.com/topic/184098-select-lowest-and-highest-values-from-int-in-database/#findComment-971935 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.