28, May 2012

add value to current value in DB - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: add value to current value in DB
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: add value to current value in DB  (Read 961 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« on: Aug 10, 2006, 07:00:10 pm »

ah yes here we go again another somewhat simple for you, hard for me task! Tongue

i want to make it so when a user logs in and completes the login form, their "user_clanrank" value is updated. instead of replacing it with a new value i want to simply add 5 to whatever is already there.. this would include login.php and a panel from where they login i suppose.. most likely you wont need to code for those pages to help me here tho Smiley


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Aug 10, 2006, 07:06:00 pm »

You have to add an SQL query which will be something like :

Code:
UPDATE users SET user_clan = user_clan + 5 WHERE userID = $userID LIMIT 1

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #2 on: Aug 10, 2006, 07:08:42 pm »

ty for refreshing my memory .. i knew the answer to this one i just .. have some memory losss.. for some reason.. Tongue ill show the working code (for what im doing) after i finish apply nik's snippet


Last blog : phpHaze 1.59.1 in Development
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #3 on: Aug 10, 2006, 07:25:20 pm »

for some reason, this code is doubling the value (i put 1, and it adds 2)

Code:
<?php /*there is more before this...*/
if (iADMIN && (iUSER_RIGHTS != "" || iUSER_RIGHTS != "C")) {
echo "<br><span class='small'><b>".$locale['on109']."</b></span><br />";
echo "<span class='small'>°</span> <a href='".ADMIN."index.php".$aidlink."' class='side'>".$locale['on110']."</a><br>\n";
echo "<span class='small'>°</span> <a href='".BASEDIR."administration/news.php".$aidlink."' class='side'>".$locale['on111']."</a><br>\n";
echo "<span class='small'>°</span> <a href='".BASEDIR."administration/articles.php".$aidlink."' class='side'>".$locale['on112']."</a><br>\n";
echo "<span class='small'>°</span> <a href='".BASEDIR."infusions/calendar_panel/calendar.php?funk=addein&km=".aidlink."' class='side'>Add Event</a><br>\n";
}
} else {
openside($locale['on122']);
echo "<div align='center'>".(isset($loginerror) ? $loginerror "")."<form name='loginform' method='post' action='".FUSION_SELF."'>".$locale['on123']."<br>";
echo "<input type='text' name='user_name' class='textbox' style='width:100px'><br>".$locale['on124']."<br>";
echo "<input type='password' name='user_pass' class='textbox' style='width:100px'><br>";
echo "<input type='checkbox' name='remember_me' value='y' title='".$locale['on125']."' style='vertical-align:middle;'>";
echo "<input type='submit' name='login' value='".$locale['on126']."' class='button'><br></form><br>\n";
dbquery('UPDATE fusion_users SET user_cpts = user_cpts + 1 LIMIT 1');
if (
$settings['enable_registration']) {
echo "".$locale['on127']."<br><br>\n";
}
echo $locale['on128']."</div>\n";
}
closeside();
?>


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #4 on: Aug 11, 2006, 08:06:24 am »

I am not sure about this.

Maybe this code is executed on every new page, or you just refreshed the page by accident.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #5 on: Aug 14, 2006, 12:37:47 am »

nope not refreshing page, but i had to take this off, it was only working for my account and no one elses (For some reason..)


Last blog : phpHaze 1.59.1 in Development
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3615
Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: add value to current value in DB
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 02:58:38 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.