xyn Posted September 21, 2006 Share Posted September 21, 2006 hey,I have a pm system for my users, and I allow each member to have 50 Pmsthis is set within the database when they register so, admins and mods getmore storable messages and I can give different users moreif i wanted etc.the problem is trying to tell php that the Database value (50 in this case)is 100% then make it calculate how much percent 3 messages would be.to us that's 6% ... but if you know what i mean?if you can help would be nice.-Ash Quote Link to comment https://forums.phpfreaks.com/topic/21517-inbox/ Share on other sites More sharing options...
Orio Posted September 21, 2006 Share Posted September 21, 2006 floor($msgs_in_inbox/$max_allowed*100);Is this good?Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21517-inbox/#findComment-95984 Share on other sites More sharing options...
HuggieBear Posted September 21, 2006 Share Posted September 21, 2006 How are you storing the information in the database? Are you storing each of the users messages in a row and then doing a count() or do you have a column in the user table that says how many messages they've sent?We're going to get MySQL to do the work for you before passing the data to the php.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/21517-inbox/#findComment-95985 Share on other sites More sharing options...
xyn Posted September 21, 2006 Author Share Posted September 21, 2006 Well their Max limit is within their user table...and their Inbox Messages is counted via mysql_num_rows();by your comment it sounds like i will need to change my codeto something like...[code=php:0]$sql = mysql_query("SELECT COUNT(*) FROM table WHERE pm_to='$variable'");$num = mysql_num_rows( $sql );[/code]if that's right, then using Orio's help; i will make...[code=php:0]$num = mysql_num_rows( $sql );$max = "50"; //would make sql get this var.$Pcent = floor($msg/$max*100);echo "<p>You are using ".$pcent."% of your Inbox quota</p>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21517-inbox/#findComment-95990 Share on other sites More sharing options...
Orio Posted September 21, 2006 Share Posted September 21, 2006 That looks good :)Orio. Quote Link to comment https://forums.phpfreaks.com/topic/21517-inbox/#findComment-95996 Share on other sites More sharing options...
xyn Posted September 21, 2006 Author Share Posted September 21, 2006 :] Yep it worked, I didn't need to use the count(); :/but it works alright thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/21517-inbox/#findComment-96041 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.