papaface Posted January 9, 2007 Share Posted January 9, 2007 Hello,How would I go about incrementing a field in a table everytime i run a query on it?I think it is something like:[code]$update = "update videos set clicks = +1 where vidid='".$id."'";[/code]^^ but that doesnt work.regards Link to comment https://forums.phpfreaks.com/topic/33528-increment-a-field/ Share on other sites More sharing options...
ToonMariner Posted January 9, 2007 Share Posted January 9, 2007 $update = "update `videos` set `clicks` = `clicks` + 1 where `vidid`= '".$id."'"; Link to comment https://forums.phpfreaks.com/topic/33528-increment-a-field/#findComment-156912 Share on other sites More sharing options...
papaface Posted January 9, 2007 Author Share Posted January 9, 2007 Thanks :) Link to comment https://forums.phpfreaks.com/topic/33528-increment-a-field/#findComment-156915 Share on other sites More sharing options...
trq Posted January 9, 2007 Share Posted January 9, 2007 All those backticks are not at all required. Link to comment https://forums.phpfreaks.com/topic/33528-increment-a-field/#findComment-156922 Share on other sites More sharing options...
Jessica Posted January 10, 2007 Share Posted January 10, 2007 Nor is the concatenation of strings. $update = "UPDATE videos SET clicks = clicks + 1 WHERE vidid = '$id'";Sometimes people like to format things the way they like best :-P Link to comment https://forums.phpfreaks.com/topic/33528-increment-a-field/#findComment-156924 Share on other sites More sharing options...
Recommended Posts