/    Sign up×
Community /Pin to ProfileBookmark

Game Hi score

I have no clue if this is possible…anyway this is what I need

Members of the forum (or just plain regular visitors) should be able to select the game they want to submit hiscores to through a drop-down menu, and be able to write name, initials, their record and an optional picture as proof, all this on a form. After that, the unknown php script checks the if’s and else’s and places that hiscore or time attack at the right position on the game’s rankings. Let’s say that I submit a record, and I beat someone’s record. That someone will drop down to second place and my record will show up as first place, and on the profile pages of each member, each of their records and current placements on the top lists should be shown there.

Thanks ALOT in Advance

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ShmohelJun 08.2005 — sounds like you need a database. Is your site designed with PHP? Do you have existing databases on your site?
Copy linkTweet thisAlerts:
@ephmynusJun 08.2005 — mysql_query("INSERT INTO db VALUES('$selected_game','$user','$initials','$hi_score','$picture_link')");

$result=mysql_query("SELECT * FROM db ORDER BY hi_score DESC");

while($row = mysql_fetch_array($result, MYSQL_BOTH))

{

print $row{'selected_game'}."<br>n";

print $row{'user'}."<br>n";

print $row{'initials'}."<br>n";

print $row{'hi_score'}."<br>n";

if ($row{'picture_link'}!="")

{

print "<img src='".$row{'picture_link'}."'><br>n";

}

}
Copy linkTweet thisAlerts:
@DPXauthorJun 08.2005 — mysql_query("INSERT INTO db VALUES('$selected_game','$user','$initials','$hi_score','$picture_link')");

$result=mysql_query("SELECT * FROM db ORDER BY hi_score DESC");

while($row = mysql_fetch_array($result, MYSQL_BOTH))

{

print $row{'selected_game'}."<br>n";

print $row{'user'}."<br>n";

print $row{'initials'}."<br>n";

print $row{'hi_score'}."<br>n";

if ($row{'picture_link'}!="")

{

print "<img src='".$row{'picture_link'}."'><br>n";

}

}[/QUOTE]



So How does this work ? where do I put it?

And yes I have PHP and a database
Copy linkTweet thisAlerts:
@ephmynusJun 09.2005 — How much do you know about MySQL? I would set up a form on your site with all the requested variables. If you're not familiar with uploading files, here you go:

[code=php]
$uploaddir = 'full/path/to/upload/directory';
$uploadfile = $uploaddir . (isset($_POST['picture_input']) && ($_POST['picture_input'] != '') ? $full_file_name : $_FILES['picture_file']['name']);

\ Picture input is the name you would like to use for the file they upload

$picture_link="http://www.domain.com/picture/directory"."$full_file_name";
[/code]


Once you have set up the form, your submission file must collect the data and input it into your database.

[code=php]mysql_query("INSERT INTO db VALUES('$selected_game','$user','$initials','$hi_score','$picture_link')");[/code]

On a query page for your users, you can retrieve the high scores by calling that information from your database in order of the highest to lowest scores.

[code=php]
$result=mysql_query("SELECT * FROM db ORDER BY hi_score DESC");

while($row = mysql_fetch_array($result, MYSQL_BOTH))
{
print $row{'selected_game'}."<br>n";
print $row{'user'}."<br>n";
print $row{'initials'}."<br>n";
print $row{'hi_score'}."<br>n";
if ($row{'picture_link'}!="")
{
print "<img src='".$row{'picture_link'}."'><br>n";
}
}
[/code]


If you would like to show only the top x scores (let's say x is 10) then you can change the result line to

[code=php]$result=mysql_query("SELECT * FROM db ORDER BY hi_score DESC LIMIT 10");[/code]

On the individual user's own page, you can change that to show their top score by saying

[code=php]$result=mysql_query("SELECT * FROM db WHERE user='$user' ORDER BY hi_score DESC LIMIT 1");[/code]
×

Success!

Help @DPX spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...