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$string
with\t
separator - and
Insert
it to Mysql. - When nessesary,
select
the field from table explode()
it to separate strings using\t
separator- remove the
$menu3
variable frome being imploded this time - again
implode()
them - and
UPDATE
the field
精彩评论