Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Query first or simple update statement
Old 06-14-2005, 04:17 AM Query first or simple update statement
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
I used to always first query the value of in this case user_refs and then increment it in php
Is it possible to simply increment user refs through the update statement. So a 100 would be something like ++ ??
PHP Code:
mysql_query("UPDATE `phpbb_users` SET `user_refs` = '100' WHERE `user_id` =2 LIMIT 1 ;") or die(mysql_error()); 
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-14-2005, 04:50 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Code:
UPDATE tablename SET fieldname=fieldname+1 WHERE whatever
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 06-14-2005, 05:16 AM
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
Oberon glad you are roaming these forums

BTW
what's that in your sig??
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
Old 06-14-2005, 05:46 AM
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
Another little question
when using this:
mysql_query("UPDATE `phpbb_stats` SET stats_refs=stats_refs+1 WHERE `stats_day` = NOW( ) LIMIT 1 ;") or die(mysql_error());
Is there anyway i can tell mysql to create a new day if stats_day = now() returns no result?
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
Old 06-14-2005, 08:04 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You could probably just run the query as you have it there, then use the PHP function mysql_affected_rows() to find out how many rows got updated. I fthis is zero you can fire of another INSERT query to put the new date in.

My sig is a 'quine' - a program that prints it's own source code, including the parts that do the printing.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 06-14-2005, 11:59 AM
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
never even knew those excisted
both your sig as that function


Thanks
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Query first or simple update statement
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39089 seconds with 12 queries