paulman888888 Posted May 30, 2008 Share Posted May 30, 2008 I have all my pages set up but i would like it so that it would only show a certain game scores. What i have at the minute is a web-page that handles all scores but does not say which game sent it. So the hi scores are kind of pointless. What i thought i could do was add a gameid. So my script could look at the gameid and store it, and when i would like to look at highscores i could type something.php?gameid=1 and it will show me everything for that game. Below are my current scripts. Please can you help me change them. uploadscore.php <?php require('connect.php'); ?> <?php mysql_query("INSERT INTO myscorev1 (name, score) VALUES('" . mysql_real_escape_string($_GET['name']) . "', '" . mysql_real_escape_string($_GET['score']) . "')") or die('Theres an error. Please try again.#'); mysql_query("SELECT count(name) as position FROM myscorev1 WHERE score > ".mysql_real_escape_string($_GET['score'])) or die('Theres an error. Please try again.#'); $row = mysql_fetch_assoc($result); $position = $row['position']+1; echo "Score Uploaded# Your Position was ".$row['position']."#"; ?> viewalldata.php <?php require('connect.php'); ?> <?php mysql_query("INSERT INTO myscorev1 (name, score) VALUES('" . mysql_real_escape_string($_GET['name']) . "', '" . mysql_real_escape_string($_GET['score']) . "')") or die('Theres an error. Please try again.#'); mysql_query("SELECT count(name) as position FROM myscorev1 WHERE score > ".mysql_real_escape_string($_GET['score'])) or die('Theres an error. Please try again.#'); $row = mysql_fetch_assoc($result); $position = $row['position']+1; echo "Score Uploaded# Your Position was ".$row['position']."#"; ?> viewscores.php <?php require('connect.php'); ?> <?php // Get all the data from the "myscorev1" table $result = mysql_query("SELECT * FROM myscorev1 ORDER BY score DESC LIMIT 0, 10") or die('O no. Theres an error#'); echo ""; echo ""; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo ""; echo $row['score']; echo "#"; } echo "#Completed"; ?> viewnames.php <?php require('connect.php'); ?> <?php // Get all the data from the "myscorev1" table $result = mysql_query("SELECT * FROM myscorev1 ORDER BY score DESC LIMIT 0, 10") or die('O no. Theres an error#'); echo ""; echo ""; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo ""; echo $row['name']; echo "#"; } echo "#Completed"; ?> viewall.php <?php require('connect.php'); ?> <?php // Get all the data from the "myscorev1" table $result = mysql_query("SELECT * FROM myscorev1 ORDER BY score DESC") or die('O no. Theres an error'); echo "<table border='1' width='20%'>"; echo "<tr> <th>Name</th> <th>Score</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['name']; echo "</td><td>"; echo $row['score']; echo "</td></tr>"; } echo "</table>"; ?> Thank-you all very much. Quote Link to comment https://forums.phpfreaks.com/topic/108014-solved-help-with-id/ Share on other sites More sharing options...
MadTechie Posted May 30, 2008 Share Posted May 30, 2008 what your asking for is pretty basic MySQL, your need to add a field called GameID then update the statements to suite $gid = (int)$_GET['id']; mysql_query("INSERT INTO myscorev1 (name, score, GameID) VALUES('" . mysql_real_escape_string($_GET['name']) . "', '" . mysql_real_escape_string($_GET['score']) . "', $gid)") or die('Theres an error. Please try again.#'); $gid = (int)$_GET['id']; $result = mysql_query("SELECT * FROM myscorev1 WHERE GameID = $gid ORDER BY score DESC LIMIT 0, 10") or die('O no. Theres an error#'); etc Quote Link to comment https://forums.phpfreaks.com/topic/108014-solved-help-with-id/#findComment-553613 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.