This topic is locked
[SOLVED]

 enter value into field from edit form on save

5/30/2012 8:55:40 AM
PHPRunner General questions
S
scoobysteve author

I would like to be able to have my members add a score to their record after they have made a edit for the first time, so when they save their record it runs the code below and adds 100 to the score1 field in their record, but right now its creating a new record and adding the 100 in the score1 record, how can I change this to add the score to the owners record
This would be in the Edit form event in "After record updated"
Thanks in advance
global $conn;

$strSQLInsert = "insert into tblproperties (score1) values (100)";

db_exec($strSQLInsert,$conn);

C
cgphp 5/30/2012

You have to update the existing record: http://www.w3schools.com/sql/sql_update.asp

S
scoobysteve author 5/30/2012



You have to update the existing record: http://www.w3schools.com/sql/sql_update.asp


I tried this but I get a syntax error, unexpected T_STRING in line 1 Is there not something I can change on the previous code to instruct it to update the current UserID,

I am stucking this in the Äfterrecord updated" event on the edit page as before
UPDATE tblproperties

SET score1='100',

WHERE INDEX='UserID'

C
cgphp 5/30/2012

Post the full code.

S
scoobysteve author 5/30/2012



Post the full code.


OK got it to work with the following
global $conn;

$strUpdate = "update tblproperties set score1='100' where UserName='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);