简体   繁体   中英

How to store a count of the number of visits to a client premises?

I am working on a project in MySQL and PHP. I want to create a database for clients and one of the columns should be how many times the client has visited the company because each time he/she gets a new reward.

What I was thinking about is make that column (for number of visits) to be a checkbox that the employee cannot choose the second number till the first one exists.

I mean the employee cannot choose 2 till 1 is chosen.

However, I don't have an idea how this can be created in MySQL. So, can anybody tell me please? Or if you have any other thoughts to do this job.

If I'm understanding correctly, the scenario is this: client visits your office and while the employee is entering data, the employee can update the number of times that the client has visited. If the client has visited 3 times before, there's a checkbox with the number "4" next to it and the employee can check that to indicate that the client visitied.

For the database, just add an integer column in the client table and add one each time you want to record a new visit.

For the user interface, how about just a button? Employee clicks the button to indicate that the client visited. You don't really want a checkbox unless you're submitting a true/false or on/off value, which doesn't seem to be the case here. What you really want is a "client visited" action.

I'm thinking something like this:

CREATE TABLE `clientVisits` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `counter` int(8) DEFAULT NULL,
    `clientID` varchar(255) DEFAULT NULL,
    `dateVisit` datetime DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

counter field is the number of visits. clientID field is the ID of client

for each visit you must press the button to increase the hit counter

for a new visit you need to update the field counter (counter + 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM