10 Replies - 1451 Views - Last Post: 15 November 2009 - 03:20 AM Rate Topic: -----

#1 Johnson-php  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 14-November 09

Points System

Posted 14 November 2009 - 10:28 PM

Hi there

I am making a points system on my site, like when someone post something on shoutbox the members get 1 point.
I tried this code
$result = mysql_query("SELECT * FROM members WHERE username='Johnson'");
$points = $result["points"];
$points += 20;
mysql_query("UPDATE members SET points = '$points' WHERE username='Johnson'");

Let me explain it again:
If the member X have 20 points and he post something on shoutbox he will have 40 points and if post again he will havbe 60...

I did a search on google and didn't find anything that could help me.

so any help here ?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Points System

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Points System

Posted 14 November 2009 - 10:44 PM

if you want to give one point then add one with your $points Example $points++ or $points = $points + 1;and also you can add one point in your update query:
example: mysql_query("UPDATE members SET `points` = `points` +1")or die(mysql_error());
Hope it helps :)
Was This Post Helpful? 1
  • +
  • -

#3 Johnson-php  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 14-November 09

Re: Points System

Posted 14 November 2009 - 11:11 PM

View Postnoorahmad, on 14 Nov, 2009 - 09:44 PM, said:

if you want to give one point then add one with your $points Example $points++ or $points = $points + 1;and also you can add one point in your update query:
example: mysql_query("UPDATE members SET `points` = `points` +1")or die(mysql_error());
Hope it helps :)


hey Thanks for the reply! :)

I tried the code above but it only stay on 1 if I update the page it just stay on 1

so the member will always have 1 point :/

I mean like this :

If member X have 1 point and he post something on shoutbox he will get 1 point and he will have 2 points

Hope it helps :-)
Was This Post Helpful? 0
  • +
  • -

#4 masashiorika  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 81
  • Joined: 06-July 09

Re: Points System

Posted 14 November 2009 - 11:11 PM

You'll probably want to change '$points' to just $points
Was This Post Helpful? 0
  • +
  • -

#5 Johnson-php  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 14-November 09

Re: Points System

Posted 14 November 2009 - 11:33 PM

View Postmasashiorika, on 14 Nov, 2009 - 10:11 PM, said:

You'll probably want to change '$points' to just $points



I mean its like points system as I said above:

if Member X have 2 points and post something on shoutbox he will get more 2 points and he will have 4 points.
Was This Post Helpful? 0
  • +
  • -

#6 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Points System

Posted 15 November 2009 - 12:11 AM

change this code:
$result = mysql_query("SELECT * FROM members WHERE username='Johnson'");
$points = $result["points"];
$points += 20;
mysql_query("UPDATE members SET points = '$points' WHERE username='Johnson'");

to this:
mysql_query("UPDATE `members` SET `points` = `points` + `points` WHERE username='Johnson'");


:)

Edit: I change the code and it doubles the points :)

This post has been edited by noorahmad: 15 November 2009 - 12:15 AM

Was This Post Helpful? 1
  • +
  • -

#7 Johnson-php  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 14-November 09

Re: Points System

Posted 15 November 2009 - 12:37 AM

View Postnoorahmad, on 14 Nov, 2009 - 11:11 PM, said:

change this code:
$result = mysql_query("SELECT * FROM members WHERE username='Johnson'");
$points = $result["points"];
$points += 20;
mysql_query("UPDATE members SET points = '$points' WHERE username='Johnson'");

to this:
mysql_query("UPDATE `members` SET `points` = `points` + `points` WHERE username='Johnson'");


:)

Edit: I change the code and it doubles the points :)


WOW! You are the God!
Many thanks mate :)
I will thank you :-))))
Was This Post Helpful? 0
  • +
  • -

#8 Johnson-php  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 14-November 09

Re: Points System

Posted 15 November 2009 - 12:49 AM

View Postnoorahmad, on 14 Nov, 2009 - 11:11 PM, said:

change this code:
$result = mysql_query("SELECT * FROM members WHERE username='Johnson'");
$points = $result["points"];
$points += 20;
mysql_query("UPDATE members SET points = '$points' WHERE username='Johnson'");

to this:
mysql_query("UPDATE `members` SET `points` = `points` + `points` WHERE username='Johnson'");


:)

Edit: I change the code and it doubles the points :)


Thanks!
but the code you give to me duplicate the value :/ is there any code to increase by 1,2,3,4,5,6,7,8 ? :-)

THANKS!

This post has been edited by Johnson-php: 15 November 2009 - 12:54 AM

Was This Post Helpful? 0
  • +
  • -

#9 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Points System

Posted 15 November 2009 - 01:10 AM

Yes!, instate of points in mysql_query("UPDATE `members` SET `points` = `points` + `points` WHERE username='Johnson'"); use 1 (one) something like this
mysql_query("UPDATE `members` SET `points` = `points` + 1 WHERE username='Johnson'");

:)
Was This Post Helpful? 1
  • +
  • -

#10 Johnson-php  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 14-November 09

Re: Points System

Posted 15 November 2009 - 01:48 AM

View Postnoorahmad, on 15 Nov, 2009 - 12:10 AM, said:

Yes!, instate of points in mysql_query("UPDATE `members` SET `points` = `points` + `points` WHERE username='Johnson'"); use 1 (one) something like this
mysql_query("UPDATE `members` SET `points` = `points` + 1 WHERE username='Johnson'");

:)


Thanks! finally I found the key to solve my problem :D

I'll thank you 1 more time :)
Was This Post Helpful? 0
  • +
  • -

#11 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Points System

Posted 15 November 2009 - 03:20 AM

You are welcome :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1