2016-11-04 56 views
0

enter image description here的MySQL服務器 - 更新值

我想更新數據Training ClassessTraining使用它的關鍵features_title_1也想做同樣的,在一個查詢記錄的其餘部分。如何我會這樣做嗎?

我知道我的查詢是錯誤的,但在這裏它..任何幫助將不勝感激..

"update home_content set 
`features_title_1` ='Training Classes' , 
`features_title_2` ='Happy Clients' , 
`features_title_3` ='Trainings Rooms' , 
`gender_title_women` ='For Womendsd', 
`gender_desc_women` ='Nulla sed lacus vitae risus, 
`gender_title_men` ='For Men', 
`gender_desc_men`  ='Nulla sed lacus vitae." 

回答

1

你可以簡單地執行MySQL查詢
這樣

$DataAarray = array("features_title_1" =>'Training Classes' , 
          "features_title_2" =>'Happy Clients' , 
          "features_title_3" =>'Trainings Rooms' , 
          "gender_title_women" =>'For Womendsd', 
          "gender_desc_women" =>'Nulla sed lacus vitae risus', 
          "gender_title_men" =>'For Men', 
          "gender_desc_men"  =>'Nulla sed lacus vitae'); 
之前創建一個數組

然後你可以有這樣的foreach和foreach你可以執行你的mysql更新查詢

foreach($DataAarray as $Key => $value){    
    //Updte query here 
    UPDATE `table` SET `value` = $value WHERE `mkey` = $Key; 
} 
+0

非常感謝。它的工作:) – syed

+0

很高興幫助... :-) –