Forum Moderators: open

Message Too Old, No Replies

Help Editing Files?

Mysql field edit

         

DaveDmd

12:26 am on May 9, 2009 (gmt 0)

10+ Year Member



I'm going nuts trying to figure this out.
I have a field in a mysql table called favorites.
in the field I have id's stored with seperators such as,
¦1001¦¦1005¦¦1009¦.
I can increment this field to keep adding ID #'s but I would like to remove partial ones also.

I would like to remove or delete ¦1005¦ in this field and keep the rest.
I tried unset array, but they are not an array as they are all in the same record same field.

Can anyone show me a mysql example how i can modify this field when needed.

Thank you....

Forgot to mention, I have a form with a checkbox. when selected the ID number is posted in the form and a command would take this id# and remove it from the field.

[edited by: DaveDmd at 12:32 am (utc) on May 9, 2009]

LifeinAsia

3:50 pm on May 11, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Welcome to Webmaster World!

You can use the REPLACE function in MySQL to accomplish what you want.

However, a better implementation may be to normalize your data and put favorites into a separate table, with one favorite per row instead of multiple favorites in a VARCHAR field.

DaveDmd

4:33 pm on May 11, 2009 (gmt 0)

10+ Year Member



got it thanks....
i did figure out the replace method..
thanks