Jump to content

Archived

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

xyn

Inbox %

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

Share this post


Link to post
Share on other sites
floor($msgs_in_inbox/$max_allowed*100);

Is this good?

Orio.

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
:] Yep it worked, I didn't need to use the count(); :/
but it works alright thanks guys!

Share this post


Link to post
Share on other sites

×

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.