Jump to content

Php Leaderboard


FutileSoul

Recommended Posts

Are the player info and ratings already stored in a database?  If so, it's a matter of a simple SELECT and a few lines of PHP to automatically show the current ratings.

 

If the players aren't stored in a database, you should make that happen.

Link to comment
Share on other sites

the players aren't in the database, i just have the players and the (+/-) in the html code

 

how would i go about putting the players in the database?

 


<table>
<font align=right>
<TH>Name</TH>
    <td></td><td></td><td></td>
<TH>+/-</TH>
<tr></tr>

<TR>
   <TD>Pat</TD>
<td></td><td></td><td></td>
   <TD>+184</TD>
<TR>
   <TD>Dez</TD>
<td></td><td></td><td></td>
   <TD>+151</TD>
<TR>
   <TD>Michaels</TD>
<td></td><td></td><td></td>
   <TD>+115</TD>
<TR>
   <TD>Seth</TD>
<td></td><td></td><td></td>
   <TD>+35</TD>
<TR>
   <TD>Aron</TD>
<td></td><td></td><td></td>
   <TD>+31</TD>
<TR>
   <TD>Cory</TD>
<td></td><td></td><td></td>
   <TD>+28</TD>
<TR>
   <TD>Ryan</TD>
<td></td><td></td><td></td>
   <TD>+3</TD>
<TR>
   <TD>Andy</TD>
<td></td><td></td><td></td>
   <TD>-6</TD>
<TR>
   <TD>Josh</TD>
<td></td><td></td><td></td>
   <TD>-40</TD>
<TR>
   <TD>Turner</TD>
<td></td><td></td><td></td>
   <TD>-40</TD>
<TR>
   <TD>Long</TD>
<td></td><td></td><td></td>
   <TD>-58</TD>
<TR>
   <TD>Adam</TD>
<td></td><td></td><td></td>
   <TD>-60</TD>
<TR>
   <TD>Justin</TD>
<td></td><td></td><td></td>
   <TD>-60</TD>
<TR>
   <TD>Gloves</TD>
<td></td><td></td><td></td>
   <TD>-70</TD>
<TR>
   <TD>Sean</TD>
<td></td><td></td><td></td>
   <TD>-160</TD>
<TR>

<td><small><small>Last Updated 3/19/07</small></small></td>



</table>



Link to comment
Share on other sites

i found this site >> http://www.tizag.com/mysqlTutorial/mysqltables.php and tried using the code (changing the db host, dbname and password, and the table name) and i get an error    "Access denied for user 'futilesoul_wp'@'82.197.131.12' to database 'test'" 

 

what am i doing wrong

 


<?php
// Make a MySQL Connection
mysql_connect("db1.awardspace.com", "futilesoul_wp", "mypassword") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE rankings(
id INT NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(id),
name VARCHAR(30), 
age INT)")
or die(mysql_error());  

echo "Table Created!";

?>

Link to comment
Share on other sites

i got the stuff coded and the data inputted into the database and it is up on patspoker.awardspace.com

 

now here comes the tricky part...

 

instead of using the following format to edit this almost daily, how would i go about making some sort of page where i could click a name and edit their score, and add new names and scores?

 

<?php
// Connect to MySQL

// Get Sandy's record from the "example" table
$result = mysql_query("UPDATE example SET age='22' WHERE age='21'") 
or die(mysql_error());  


$result = mysql_query("SELECT * FROM example WHERE age='22'") 
or die(mysql_error());  

// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $result );
echo $row['name']." - ".$row['age']. "<br />";
?>

Link to comment
Share on other sites

Personally I would set up a form for yourself in html. Playername  and new stat field. Then create a php page that the form posts to. In that page you will have something like $player = $_POST['player']; and $stat = $_POST['stat']; Those need to match what you posted. Then connect to your db. Followed by:

$sql = mysql_query(UPDATE `table_name` SET `player` = '$player', stat = '$stat' WHERE player = '$player'") or die(mysql_error());  

That should update the stats for you. Or you could always create a dynamic link to a php page that will echo the players name and ask you for the new stat. And upon clicking a submit button it would do my previous update.

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.