Current location: Hot Scripts Forums » Programming Languages » PHP » update certain fields using SQL


update certain fields using SQL

Reply
  #1 (permalink)  
Old 07-01-04, 04:59 PM
APuppyDog APuppyDog is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
update certain fields using SQL

Hi, i would like to change my users points. Some of them have points that are like 11.. i would like any points that are less than 50 to be 50 PLUS the amount they have...

so something like this

SELECT * FROM `phpbb_users` WHERE 'user_points' less than 50, user_points = user_points + 50

is this possible?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-01-04, 08:50 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah you have good pseudocode.

www.w3cschools.com and read up on the sql.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-02-04, 12:43 PM
APuppyDog APuppyDog is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by infinitylimit
read up on the sql.

thanks, but thats of no help, i tried reading the UPDATE query but it doesn't apply since i don't know how to do less than or equal to..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-02-04, 01:38 PM
kasper's Avatar
kasper kasper is offline
Newbie Coder
 
Join Date: Jun 2004
Location: CA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
http://www.w3schools.com/php/php_operators.asp

the page IL gave you has all the operators and conditionals of php and what you need to complete your update.

the less than equal to operator on that page is <=
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-02-04, 01:53 PM
APuppyDog APuppyDog is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
thanks, this is what i used.

UPDATE phpbb_users SET user_points=user_points+50 WHERE user_points <= 50;

worked like a charm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formmail problem gscraper Perl 12 08-27-04 04:06 AM
Urgent! Update fields problem Ogmios PHP 1 05-12-04 01:59 AM
Help with ASP & FORMS blessedrub ASP 0 01-23-04 11:22 AM
ASP Calendar..HELP...pls jimthepict ASP 1 07-31-03 06:01 PM
change my field in this example sal21 ASP 3 07-14-03 03:49 AM


All times are GMT -5. The time now is 07:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.