Uncomplicated update

Asked

Viewed 50 times

-2

Hello a good evening to all first, my doubt is the following... on my site I have a system of visits it works as follows

if( there is no session visit){

$handle = "picks up the visit fields in the bank";

$array = mysqli fetch array on the curry handle

$visit = $array['field name'] + 1;

$alters = give an update in the visits field with the visit variable

sets the session visit below }

my doubt is as follows, would not have some way to be doing a more uncomplicated update ? ex:

$visit = update visits set visits + 1

You know what I mean? with just a query already amenta an extra number in my counter of visits, without need to indent the fields to make a fetch array and only after the update, I thank you for your help, happy new year to all of you !!

1 answer

0

As far as I’m concerned, you just want to add one to the variable visits, so it would be:

UPDATE table_name SET visitas = (visitas + 1) WHERE condicao

Browser other questions tagged

You are not signed in. Login or sign up in order to post.