Update MYSQL and SET particular row Content
I am trying to update my table t1 which has rows as following :-
- id
- 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
- You can
implode()them as a single$stringwith\tseparator - and
Insertit to Mysql. - When nessesary,
selectthe field from table explode()it to separate strings using\tseparator- remove the
$menu3variable frome being imploded this time - again
implode()them - and
UPDATEthe field
加载中,请稍侯......
精彩评论