Automaticaly Update Sql Db!

Started on the old forum in September 2007 · view the original in the archive · old links redirect here

20 replies · 1,776 views · started 19 years ago · 1 min read

2 participants
Guest #1

Does any wap master know how to code automaticaly database update for evry 24 hours.. if u r not clear my point.. here is an examp e.. lets suppose dat every users pluses shud be updated (added) with 5 plusses i  every 24 houres automaticaly... how to code dat... plz post here.thanx External image (may be gone)

blackhowk Senior · 411 posts #2

$now = time(); $start=date("Y-m-d")." 23:00:00"; $end=date("Y-m-d")." 23:01:00";

$tstamp1=strtotime($start); $tstamp2=strtotime($end); if($now>$tstamp1 && $now<$tstamp2) {

$sql = 'UPDATE ibwf_users SET plusses = plusses +5'; mysql_query($sql); }

23:00 to 23:01 - interval on each day - this interval must be more shortly in order to update only once. and you need to have at least one user online in this hour.

Guest #3

thanx dude.. in which hour at least one use need indeed in da wap? and wr to put dis code?

blackhowk Senior · 411 posts #4

thanx dude.. in which hour at least one use need indeed in da wap? and wr to put dis code?

i dont use this site, put in the INDEX.PHP in login zone or autentification zone or main zone, dnno. and what is hour when at least one user..use your wap site.... dnno... External image (may be gone)

Guest #5

perfect thanx again! i got wat u meant.. here is my last Q if we suppose to add 10%plusses to users only for who alredy got plusses,, how to code that?

blackhowk Senior · 411 posts #6

i dont understand, you want to add plussess in procent? and you want to add plussess only for who alredy got 10%plusses? whay in procent?

more simple is 1,2,3,4,5 plussess for each visit. who dont make visits dont have plussess.

Guest #7

i meant...Ex: all the users who have more than 100 plusses.... they shud be added  20 % plusses on thier credits  ...

ill explain it more

lets suppose dat i hv 200 plusses i want to update my plusses with 20% plusses., finaly i shud hv 240, coz

(200*120 )/100=240

hope u understand now

plz post here hw to code it...

blackhowk Senior · 411 posts #8

UPDATE ibwf_users SET plusses = plusses +40 WHERE plusses < '201'

this is for users who have 200 plusses and you want to add for each 40 in order to obtain 20% more.

UPDATE ibwf_users SET plusses = plusses +20 WHERE plusses < '101'

this is your first quiz , users who have 100 plusses and you want to add for each 20 in order to obtain 20%more

the sql end the add when plusses in database is equal or more like condition WHERE

if you want change the operator sign < into >

is ok now?

Guest #9

well i guess u want to add a particualr percentage to of already earned plusses to those users.. not only more than 100 or 200. Just take plusses to a variable. multiply the value from the percentage u want. Add it to the variable and thats it.

Guest #10

yes pamod u rite! u got wat i meant. actualy i neead to kno da codes of add a particualr percentage to of already earned plusses to those users...

Guest #11

ok araa try this..

CODE$now = time(); $start=date("Y-m-d")." 23:00:00"; $end=date("Y-m-d")." 23:01:00";

$tstamp1=strtotime($start); $tstamp2=strtotime($end); if($now>$tstamp1 && $now<$tstamp2) { $sql = 'UPDATE ibwf_users SET plusses = plusses * 1.2 WHERE plusses > 100'; mysql_query($sql); }

U can add it to index.php and at least a single user shud be there when ur server time is 23.00 Adjust time accordingly... External image (may be gone)

Guest #14

hey i was trying something similar to this but couldn't get it right, im trying to update chat.php, i want to give users 1 plus for every 5 chat posts they make. but very confused with.

blackhowk Senior · 411 posts #15

to get points for 5 chat lines you must select and count the last 5 lines by user and by chatroom name.

like SELECT COUNT(chatter) from ibwf_chat where chatter = 3 // each user have one id

if this result is equal with 5{

make the update }

there is a problem. if the automatic refresh run two time, and user count is 5 , the update in database is double...

WhiteWarrior Principal · 1,419 posts #16

lol pamod, the code you gave will update plusses yeah, but it will update anyones plusses if the clock hits (what ever time) you put... someone could have like 50000 plusses and they would get more if there online on the index.php at the time you put

Guest #17

to get points for 5 chat lines you must select and count the last 5 lines by user and by chatroom name.

like SELECT COUNT(chatter) from ibwf_chat where chatter = 3 // each user have one id

if this result is equal with 5{

make the update } there is a problem. if the automatic refresh run two time, and user count is 5 , the update in database is double...

yes that would be big problem, but is there any alternative solution? like i was thinking to do it from the chat points(posts) in profile. whenever 5 chat points increases in their profile, then add 1 plus to the user. exactly im not getting how to code it. can u help me please!

blackhowk Senior · 411 posts #18

i dont understand, do you want to see where is the insert with point, what insert for each action or to make one update with condition in index, chat or else?

if you want to update you must decide what and for that you need some conditions.explain.

Guest #19

Has anyone tried setting corn jobs??If yes Post here plz

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close