PC Nerd Posted January 7, 2007 Share Posted January 7, 2007 im creating a webgame, and when i create a new account.... i want to make that new account the lowest rank. how would i do that??? like l8a in the gazme, your rank woul dbe determined and chenged according to how you are going, but when you begin in the game........your the least experienced, also the lowest rank???? Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/ Share on other sites More sharing options...
TEENFRONT Posted January 7, 2007 Share Posted January 7, 2007 give the column a default value of 1? then have your ranks go from 1 to 10 as the game progresses? Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-154931 Share on other sites More sharing options...
PC Nerd Posted January 7, 2007 Author Share Posted January 7, 2007 but if you start with the rank of 100, you might end up having the rank or 54 within a week.....? Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-154936 Share on other sites More sharing options...
TEENFRONT Posted January 7, 2007 Share Posted January 7, 2007 i dont get what your trying to say.. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-154939 Share on other sites More sharing options...
PC Nerd Posted January 7, 2007 Author Share Posted January 7, 2007 well basicaly i need a way to find the highest number in the rank field, and make the new record equal ++1 to that rank. i cant just set a rank when they sign up.... because their rank will change according their activeness and scores on the site.... so it has to start off as the lowest rank and then itll be changed Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-154946 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 Your question makes little sense. Define the lowest rank. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-154948 Share on other sites More sharing options...
PC Nerd Posted January 7, 2007 Author Share Posted January 7, 2007 well if there are 10 users in total, then the lowest rank will be 10, and the highest rank will be 1. what i want to do is: egadd an 11th user. but how would i create his rank to be the lowest, if i dont know the current lowest. what sort of query or code would i need.??sorry about not explaining as well as i could havePC Nerd Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-154957 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 If you dont know the current lowest then its impossible. You still need to be alot clearer in your explination, but the logic is a simple as querying your currents ranks for the lowest, once you have the lowest, take one from it to make the new value the lowest.I think half the problem in your explination is your wording. For instance, common math states that 10 is [b]higher[/i] then 1. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-154965 Share on other sites More sharing options...
PC Nerd Posted January 7, 2007 Author Share Posted January 7, 2007 yes i agree with you in maths..... but is the winners not 1'st, and the last not 10'th??? lol so were looking for the highest number( ie lowest rank)i definately want that to be the way that its stored, decauase that determins in what order they are displayed in a different secteion of the website.thanks for your help everyone Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155276 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 The logic is still as stated above. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155304 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 ok, i think that if a make a query that finds the total number of records in the General_Stats table, then made the new record rank that query output number +1, would make the new record the lowest rank according the logic that was stated above.????? but my question is.... what query would this be? i want to find the length of the database really?,, can anyone help with this Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155360 Share on other sites More sharing options...
Jessica Posted January 8, 2007 Share Posted January 8, 2007 0 is always lowest. If they've just joined, they have no rank at all. As they gain rank, update it to go higher. Then when you list them, THEN you reverse the numbers so the person with the highest (say 1473) is 1, and the next (1247) is 2, etc. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155362 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 well that would be too hard to do, becauase your always getting new members..... so one day the 1456 record might be first, but the next might be 1467 is the first rank. what i want to do is retreive the total number of records in the table and store it as an integer, how do i do that??? Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155367 Share on other sites More sharing options...
Jessica Posted January 8, 2007 Share Posted January 8, 2007 What you're saying doesn't make any sense.Are you saying people will never change rank?I think you're approaching a goal from the wrong direction. Maybe there is a better way to address this... Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155372 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 I agree with jesirose here, your logic is arse about. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155377 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 ok, here is my my idea, if you dont understand.....10 users alreadyU1U2U3U4U5U6U7U8U9U10of the rank 1. U12. U23. U34. U45. U56. U67. U78. U89. U910. U10WITHIN A WEEK IT LOOKS LIKE THIS:1. U22. U33. U54. U45. U16. U87. U68. U79. U1010. U9now if i create a new user, i want him to have the lowest rank, ie 11. and the new user being U111. U22. U13. U34. U45. U96. U67. U58. U79. U810. U1011. U11so as always, the new user will be the lowest rank, until they are active on the website and then they earn like points to raise the rankso the lowest rank, will the the total number of records in the table (ie the number of users) so the new player will be the total number of users, +1i hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155383 Share on other sites More sharing options...
Azu Posted January 8, 2007 Share Posted January 8, 2007 The best way to do what you are trying to accomplish is to store the current amount of registered players in a sql table so if you have 123 people then it will be 123.Then when someone signs up, fetch that number, and add 1 to it, and set there rank to that. And also set the stored number to that, so that it will always be up to date.Another way is to run a query to check how many rows there are in a table (1 for each player) and add 1 to that and use that for their rank. Then you won't have to have the number written down anywhere, but this way is much slower, it will take a lot longer, and could bring your server to it's knees if there ends up being a lot of members. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155388 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 Its not that we dont understand, its just your logic is backward. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155389 Share on other sites More sharing options...
Jessica Posted January 8, 2007 Share Posted January 8, 2007 You could store their POINTS instead of their rank, and then have your code determine the rank. So a user STARTS at 0, and as they gain points, you store their POINTS. Then when you want to calculate the ranks, you select them ordered by the POINTS. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155390 Share on other sites More sharing options...
Azu Posted January 8, 2007 Share Posted January 8, 2007 My solution isn't working for you? ??? Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155404 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 Hehe... check out [url=http://www.phpfreaks.com/forums/index.php/topic,121439.0.html]this[/url] thread. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155406 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 thanks, that thread is a great help..... can i just ask.... does the mysql_num rows.... a) contact a mysql v5 or does it need to be mysqli_num_rows....... and b) does it return an integar or something similar, so you could go like..... ( using the therad as the base example)[code]$ranks = mysqli_num_rows($query);$New_P:layer_Rank = $ranks +1;[/code]would that work....?thanks for all you help Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155408 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 Your missing the point. Read that thread agin. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155411 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 i understand this post, im asking a differetn question.... what the function of the mysqli_num_rows returns, and how to store it in a variable..... could someone just answer that, or can you not store it....? Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155417 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 mysqli_num_rows returns the number of records found by your query, and yes, of course you can store it.[code=php:0]$records = mysqli_num_rows($result);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/#findComment-155426 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.