Hi,
Not sure if this is the right place to ask this, so please move if it's not.
I've been working with a ezRPG game, and trying to modify it some to make it a little more unique.
One of the things I would like to do is on the users profile page, is display their win percentage (I have this part done), and also a little icon next to their percentage. This icon that displays will depend on 2 things, the total number of battles, and their win percentage.
So if they reach the min level for the next icon (for example 200 wins) they also need to keep their win percentage above 60% to get the new icon. If they fall below 60% they get the icon ('easy target')
So I'm trying to figure out how to do this.
I've made a new table in my database it has these fields 'minimum_wins' (wins needed to get new icon), icon_path (path to image), rank_description (text to describe the icon)
but the part I can't figure out how to do is code the PHP to display the right icons.
How would I write the query for something like this?
anyone have any ideas?
Display image if user reaches certain pecentage
Moderator: General Moderators
- hawkenterprises
- Forum Commoner
- Posts: 54
- Joined: Thu Feb 28, 2008 9:56 pm
- Location: gresham,oregon
- Contact:
Re: Display image if user reaches certain pecentage
Perhaps there is an ezRPG guru on here but basically what you would want to do is find the page that is outputting the actual data, this can be hard sometimes. What I do is navigate in a browser to that page and note the filename, then try and find that filename on your server and search within the file for some type of html code. If you have grep access you life can be easier. If it has a templating system it might be parted out in other folders.
From there do you best to find the place to put the icon, sometimes echoing out data is the best way to find the spot. Now once there you should be able to find a database handle from within the program, most the time these are named something smart like $db or $conn, but I've seen all kinds. Make your queries, do the math, grab the appropriate icon and output all in that spot. This is certainly will be considered a very hacky way to accomplish the task but what do you care, as long as it works right?
If your thinking about repackaging and selling you should approach this a bit more elegantly like finding the proper places to put your code and following the proper development channels. (sigh)
From there do you best to find the place to put the icon, sometimes echoing out data is the best way to find the spot. Now once there you should be able to find a database handle from within the program, most the time these are named something smart like $db or $conn, but I've seen all kinds. Make your queries, do the math, grab the appropriate icon and output all in that spot. This is certainly will be considered a very hacky way to accomplish the task but what do you care, as long as it works right?
If your thinking about repackaging and selling you should approach this a bit more elegantly like finding the proper places to put your code and following the proper development channels. (sigh)
Re: Display image if user reaches certain pecentage
Thanks for replying,hawkenterprises wrote:Perhaps there is an ezRPG guru on here but basically what you would want to do is find the page that is outputting the actual data, this can be hard sometimes. What I do is navigate in a browser to that page and note the filename, then try and find that filename on your server and search within the file for some type of html code. If you have grep access you life can be easier. If it has a templating system it might be parted out in other folders.
From there do you best to find the place to put the icon, sometimes echoing out data is the best way to find the spot. Now once there you should be able to find a database handle from within the program, most the time these are named something smart like $db or $conn, but I've seen all kinds. Make your queries, do the math, grab the appropriate icon and output all in that spot. This is certainly will be considered a very hacky way to accomplish the task but what do you care, as long as it works right?
If your thinking about repackaging and selling you should approach this a bit more elegantly like finding the proper places to put your code and following the proper development channels. (sigh)
I know which pages I want to put the icon, on the profile.php and also home.php.
I'm just not sure how to write the query, I'm guessing it would have to be some sort of IF/Else type of statement too. It has to first get the total battles the person has been in, and then check to make sure their win percentage is above 60%. If above 60, they get the current level icon. If under, easy target.
Here is the home.php, You can see where I've added the calculation to get the percent wins.
- Attachments
-
- home.zip
- (1.21 KiB) Downloaded 5 times
- hawkenterprises
- Forum Commoner
- Posts: 54
- Joined: Thu Feb 28, 2008 9:56 pm
- Location: gresham,oregon
- Contact:
Re: Display image if user reaches certain pecentage
I'm not going to code it for you but this is the pseudo-code you would want to use for that
Something like that is what you will be doing.
Code: Select all
$percentage = $userbattles/$userswins;
if($percentage<.60){
// output easy target icon
}
elseif($percentage> .60){
// output don't f' with icon
}