How do i re-write data into a column?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hoopsmax
Forum Newbie
Posts: 2
Joined: Sat Aug 31, 2002 1:55 am
Location: Canada
Contact:

How do i re-write data into a column?

Post by hoopsmax »

I want to count how many views a link gets .. but i dont want a new line to be created every time a person clicks a link ...

Is there a way that I can take the original value from the database ... (i know this part) and then add one that that value .... then re-write the new value into the same field you took the old value from?

Please Help.

THANKS
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post by gotDNS »

get the value, (say it's ZERO) from the DB:

Code: Select all

$value = $rowї'value'];
or w/e you do...make it = $value or something, then:

Code: Select all

$value = $value+1;
^ on the page that you want the count for...then right after that, an SQL query:

Code: Select all

"insert into DBName set page_count='$value'";
..that should do it....

later on, -Brian
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

uhm more like

"UPDATE table SET foo = 'foo+1' WHERE bar = 'foobar'"
hoopsmax
Forum Newbie
Posts: 2
Joined: Sat Aug 31, 2002 1:55 am
Location: Canada
Contact:

thanks

Post by hoopsmax »

Thanks guys
Post Reply