SirChick Posted August 15, 2007 Share Posted August 15, 2007 Is there a way to do this: say i have a field as "crimeexp" say the value of crimeexp is 12 Now cos its integer format i want to just add to it instead of replacing. So something like: $CrimeEXP = ['crimeexp']; $CrimeEXP + 12; so the new value is now 24. then some how make that new $CrimeEXP be the value in the table ? Or do i have to insert and if so will it overwrite the present data in that field? or will it just add to it like this: "1212" ? Link to comment https://forums.phpfreaks.com/topic/65098-changing-data-in-a-field-without-insert/ Share on other sites More sharing options...
SirChick Posted August 15, 2007 Author Share Posted August 15, 2007 that was ment to say 1224 at the end not 1212 .. for some reason the modify button has dissapeared.. so im sorry for the double post. Link to comment https://forums.phpfreaks.com/topic/65098-changing-data-in-a-field-without-insert/#findComment-324902 Share on other sites More sharing options...
PC Nerd Posted August 15, 2007 Share Posted August 15, 2007 not sure, but look in the manual for the to_int() function. itll convert it to an integer for you. its accepted the html frm as text. not sure if thers an atrubute to change so that int isthe default datatype.... but itsbetter you do validation here. Link to comment https://forums.phpfreaks.com/topic/65098-changing-data-in-a-field-without-insert/#findComment-324941 Share on other sites More sharing options...
SirChick Posted August 15, 2007 Author Share Posted August 15, 2007 no no. Basically this is what happens in logical sense: Crime exp is 12 right...(in user table) Now when the script runs this is what the script should do : crimeexp + 12 = crimeexp 12 + 12 = 24 so now in the table crimeexp will say 24 instead of 12... you get me ? in the table crimeexp is set as integer i was thinking like "UPDATE tablename WHERE crimeexp * +12 " Link to comment https://forums.phpfreaks.com/topic/65098-changing-data-in-a-field-without-insert/#findComment-324945 Share on other sites More sharing options...
mdnghtblue Posted August 15, 2007 Share Posted August 15, 2007 mysql_query("UPDATE tablename SET crimeexp=crimeexp+12;") Is that what you're looking for? *crosses fingers* Link to comment https://forums.phpfreaks.com/topic/65098-changing-data-in-a-field-without-insert/#findComment-325024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.