Firstly I would dispense with the whole IP concept and do this with cookies; record a hit on the page and then set a cookie. That way the same user (strictly same machine) will not count as another visitor unless the cookie expires or they delete it.
basic code (untested) for one property only
Code: Select all
if(!isset($_COOKIES['visited'])) {
mysql_query('UPDATE properties SET visits = visits + 1 WHERE property_id = '.$id);
}
however to do it for multiple properties you will want to store all properties visited into one cookie e.g. as a serialised array and then check the specific index for the current property.
Alternatively you could have a seperate property_visits table, assign a unique ID into a cookie for the user and then store which properties they have visited in the DB. I have not gone for this approach above as it does not scale well for all scenarios and I don't know how many visitors/properties you will have. The DB approach does however offer much more potential for data mining later if that is important to you (e.g. average number of properties a visitor visits).
The problem(s) with using IP are 1) it forces you to have the extra DB table 2) IP is _not_ a reliable gauge of individual web users, some proxy IP addresses cover thousands (if not more) of users.
If I had more time I would do a full solution but I don't right now, sorry.
HTH,
Dai