开发者

Update MYSQL and SET particular row Content

I am trying to update my table t1 which has rows as following :-

  1. id
  2. menu

Currently i am having data in it as

id = "1"  
menu = "menu1 ,menu2 ,menu3, menu4"   

I am using explode m开发者_如何学编程ethod of PHP to get MENU row of my table t1.

$show_data = mysql_query("SELECT menu FROM t1");
$showrow  = mysql_fetch_assoc($show_data);
$showmenu =  $showrow['menu'];
$pieces = explode(",", $showmenu);

Now I want to delete content menu3 from row MENU , Please provide me which query should i use , UPDATE , ALTER or DELETE.


You should store your menus in a separate table, linked to this one by a unique identifier.

Then edit that table in the usual way.


It is better to separate $menu1 $manu2 $menu3 and $menu4

  1. You can implode() them as a single $string with \t separator
  2. and Insert it to Mysql.
  3. When nessesary,select the field from table
  4. explode() it to separate strings using \t separator
  5. remove the $menu3 variable frome being imploded this time
  6. again implode() them
  7. and UPDATE the field
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜