How to update this kind of data using php?(0-0-0-0-0)

Discussion in 'PHP' started by MinuwayWebAssets, Jan 16, 2012.

  1. #1
    Guys I really need your help,

    Im modifying a script but dont know how to update this kind of data:

    So the sql table is "towns" and I want to update "resources" the data under resources is 0-0-0-0-0 (food-water-stone-wood-gold)

    So lets say I want to update gold only? how can I do that? Please help me guys
     
    MinuwayWebAssets, Jan 16, 2012 IP
  2. modz

    modz Well-Known Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #2
    You can get the value of the field, then use explode() to make an array containing the values for gold and the other stuff and then update using the new gold value.
    If the zeros are constants, it is pointless to use explode(), you should just update to e.g. 0-0-0-$gold-0
    There may be a SQL function which could help you, but I am not familiar with it so deeply.
     
    modz, Jan 17, 2012 IP