Jump to content

Inbox %


xyn

Recommended Posts

hey,
I have a pm system for my users, and I allow each member to have 50 Pms
this is set within the database when they register so, admins and mods get
more 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
Link to comment
https://forums.phpfreaks.com/topic/21517-inbox/
Share on other sites

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.

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/21517-inbox/#findComment-95985
Share on other sites

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 code
to 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]
Link to comment
https://forums.phpfreaks.com/topic/21517-inbox/#findComment-95990
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.