Home  >  Article  >  Backend Development  >  新手请问PHP怎么对MYSQL存储和查询字符串数据

新手请问PHP怎么对MYSQL存储和查询字符串数据

WBOY
WBOYOriginal
2016-06-13 11:57:51958browse

新手请教PHP如何对MYSQL存储和查询字符串数据?
我有这样的数据。
星期一
上午:语文
下午:数学

星期二
上午:英语
下午:物理

星期三
上午:体育
下午:音乐

星期四
上午:化学
下午:美术

星期五
上午:历史
下午:政治


如何用字符串方式存储到某表的一个字段中。语法怎么写?存储以后又如何查询?如何更新上午和下午的值?

我记得以前我看过这样的文章,
类似于
[{星期一:语文,数学},{星期二:英语,物理},]
这样的方式,但具体我也不知道怎么写,语法又如何。

要求:能够查询和更新。

求大虾指点迷津。或者给个相关的文章让我自行学习。
------解决方案--------------------

<br />$arr = array(<br />    '星期一'=>'语文,数学',<br />    '星期二'=>'英语,物理',<br />    '星期三'=>'体育,音乐',<br />    '星期四'=>'化学,美术',<br />    '星期五'=>'历史,政治'<br />);<br />$result = json_encode($arr);<br />echo $result;//存如数据库<br />//从数据库中取出<br />$arr = json_decode($result, true);<br />print_r($arr);<br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn