WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

How can I update an existing record if it exists in mysql or create a new one if it doesn't?

donhalt

New member

0

0%

Status

Offline

Posts

21

Likes

0

Rep

0

Bits

125

5

Months of Service

0%
Hello everyone. First of all, I would like to briefly mention my project. I have created a system where profile visitors are recorded, but it keeps duplicating the same entry every time. For example, in the table, we have columns for ID, visitor ID, visitor, and visit date, with entries like:
1 - 30 - 2 - visit time 2
2 - 30 - 2 - visit time 3
3 - 30 - 2 - visit time 4

I do not want it to be like this. For instance, when user with ID 30 visits user with ID 2, it should check if a similar record exists before. If it does, it should only update the visit time. If not, it should create a new entry. How can I achieve this? Can you help me with this?
 

249

6,622

6,642

Top