Forum Moderators: coopster

Message Too Old, No Replies

MYSQL query help

         

redfoxhound

7:30 pm on Feb 25, 2009 (gmt 0)

10+ Year Member



Hi what is the php query to update data with another data on the same row?

example:

id ¦ poster ¦ post ¦ lastposter ¦

now I want to set it so when I delete a reply lastposter becomes poster.

Please need help. Thanks

henry0

10:27 pm on Feb 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi rfh,
UPDATE
my_table
SET
name_of_field='poster'
WHERE
id='$id'

You also need to review:
Basic of DB query [webmasterworld.com]

redfoxhound

3:13 pm on Feb 26, 2009 (gmt 0)

10+ Year Member



Would it be

UPDATE
my_table
SET
lastposter='poster'
WHERE
id='$id'

henry0

3:27 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sure, whatever is the name
give it a try

LifeinAsia

4:35 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What happens if there is more than 1 reply?

redfoxhound

5:08 pm on Feb 26, 2009 (gmt 0)

10+ Year Member



Well whom ever is the last person to create a reply then their name would be the one on the lastposter. Then if there is moderation and those replies get deleted up to the point where there are 0 reply.. then lastposter would be the poster

LifeinAsia

5:17 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



But if there are 2 replies and you delete 1, you are resetting the "lastposter" field to "poster" (i.e., the original poster) instead of the person who wrote the other reply. Right? Or am I missing something?

henry0

10:13 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then why not adding a timestamp
and rely on it for all operations/queries