Jump to content


Photo

increment by one help


  • Please log in to reply
5 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 May 2006 - 03:04 AM

Advance thank you.

In my database i have added a field called clicks, each time a user submits new data i want that table clicks increment by one but haveing trouble please help.


if($_POST(["submit"]) {

$db=mysql_connect("localhost");
mysql_select_db("promotor", $db);
$query="INSERT INTO users VALUES('$id','$password','$score','$clicks');
$result=mysql_query($query);

while($clicks=mysql_fetch_assoc($result)) {
$clicks++;
}




Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 May 2006 - 03:14 AM

Does this make sence cheers.

I wonder if theres a way to get the query to increment by one.

if($_POST(["submit"])) {

$db=mysql_connect("localhost");
mysql_select_db("promotor", $db);

$query="INSERT INTO users VALUES('$id','$password','$score','$clicks' where clicks='$clicks'+1);

$result=mysql_query($query);


}


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 19 May 2006 - 03:21 AM

I believe you want to use the UPDATE feature

ie
$result = mysql_query("UPDATE USERS SET click=click+'1' WHERE user = $some_user_id") 
or die(mysql_error());

might not be EXACTLY correct but it gives you the general idea - simply look in th ephp/mysql manual for UPDATE

LITE...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 May 2006 - 03:26 AM

sorry silly me the update was it, I need to no if the clicks=$clicks+'1' does the increment and keeps adding a 1 one to the total cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 19 May 2006 - 03:59 AM

yep...

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
If you access a column from tbl_name in an expression, UPDATE uses the current value of the column. For example, the following statement sets the age column to one more than its current value:

UPDATE persondata SET age=age+1;
[/quote]

[a href=\"http://dev.mysql.com/doc/refman/5.0/en/update.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/update.html[/a]

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 May 2006 - 04:12 AM

[!--quoteo(post=375129:date=May 19 2006, 03:59 AM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ May 19 2006, 03:59 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
yep...
[a href=\"http://dev.mysql.com/doc/refman/5.0/en/update.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/update.html[/a]

Lite...
[/quote]
Thank you so much.

I read that topic a while back and got the book but forgot cheers.


[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]soved[!--sizec--][/span][!--/sizec--]


ps. Thank you for your time.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users