Listing members with points

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Listing members with points

Post by HaVoC »

I'm trying to list players with points. So I'd do this

Code: Select all

<?php
if ($points > 0){
fdgdsfg
}
?>
Easy right? Well here's the tricky bit. When someone loses, they lose 1 point. How do I list people with points, and with negatory points, like -1 and -2?
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

Code: Select all

<?php
$points -=2;
?>
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

Uh...what's that? lol
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

$points = your variable

- = minus

= = is

2 = is a number

combined, they make the calculation,...

Code: Select all

$points - = 2;
Like this code will add 2 points:

Code: Select all

$points + = 2;
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

How does that list players with negatory points? I don't want to take their points away. I've already done that. Some players have a score of -1. How do I make the PHP display that?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

if ($points < 0){ ??
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

Don't worry about it. I'll find out a way. Your way will only show people who have less than 0 points. =/
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

correct me if i'm wrong, but:

isnt any number below dead "zero" considered negative? :?:
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

If $points exists:

Code: Select all

<?php
if (isset($points)){
fdgdsfg
}

?>
Just make sure people who never played don't have 0 in their $points.
Or you could use:

Code: Select all

<?php
if (($points>0)or($points<0)){
fdgdsfg
}
?>
But people who had their points reduced to 0 won't appear.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you want to get those with points less than or equal to zero, you can do:

Code: Select all

if ($points <= 0) {
If you want to show everybody with points (positive, 0 or negative), then take out the if statement.

Have a read of:
http://php.net/manual/en/language.opera ... arison.php

Mac
Post Reply