Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

PLEASE Help - Incrementing record count

Posted 26 Jul 2006 10:32:48
1
has voted
26 Jul 2006 10:32:48 Jeff McDonald posted:
hi guys

This is my first post and I really hope someone can help me out. I’m working with Dreamweaver 8 and developing using PHP. I think some of you might easily have an answer to my question since I’m a newbie.

I have a database with 2 tables:

“users” table with fields like:
- name
- city (int)
- and many more fields…

“cities” table with fields like:
- cityID (int)
- cityName
- and more fields
- cityCounter (default is 0)

users.city is related to cities.cityID

Now here is my problem:

I created a registration form where the user fills in all his information and when he clicks on submit data is submitted to the database. This part is working perfectly.

<b>What I want to do is also increment the “cityCounter” of the chosen city by 1 when the user clicks on submit. </b> I’ve been trying to figure out how for like 5 hours now and still can’t do it

Note that I’m barely writing any bare php and I’m using all of dreamweavers tools. Hope someone cane help out please.

Replies

Replied 27 Jul 2006 13:26:01
27 Jul 2006 13:26:01 Paul Rodger replied:
This is your perfect chance to actually code some PHP by hand <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

What you need to do is to create an sql query that looks something like this (im pressuming your using mysql)

update cities
set cityCounter = cityCounter + 1;

Just as a side note, it would be better if your renamed users.city to users.cityID so that it corresponds with the same name given in cities. It just makes your table schema that little bit clearer.

Reply to this topic