Jump to content

UPDATE incrementally


xcandiottix

Recommended Posts

I have a table that I am using UPDATE when someone creates a post. Is there a way to incrementally increase the table with out loading the value of the field first?

 

Ex:

mysql_query("UPDATE table SET Time='$date' AND Replies++ WHERE Topics='$topic'");

 

The above doesn't work but i'd rather make this work instead of querying the DB for the value, adding one, and then updating.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/213169-update-incrementally/
Share on other sites

Hey man, long time. You should be able to:

$query = "UPDATE table SET Time='$date' AND replies=replies+1 WHERE Topics='$topic'";

let me know how that works out for ya  ;)

 

I messed you up by accident:

$query = "UPDATE table SET Time='$date',replies=replies+1 WHERE Topics='$topic'";

No AND ..  :P but yes this worked perfectly... saves me a big headache. Thanks man!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.