存储和检索序列化的HTML

时间:2013-07-06 12:52:17

标签: php html wordpress serialization store

如何在PHP和MYSQL DB中存储一个或多个HTML结构,

<li class='ui-state-default ui-sortable full w4-4'>
<div class='element-handler'>
<a href='#edit-element' class='edit revs-edit-element'>Edit</a>
<a href='#del' class='del-element delete'>X</a>
</div>
<div class='element'>
<span class='element-name'>Element name</span>
</div>
<textarea rows='6' cols='10' class='text-shortcode'>
[revs_flexslider page='home'] [shortcode page='home']
[shortcode page='home'][revs_shortcode page='home']
</textarea>
</li>

并将其追加以追加

<ul id="contenitore" class="connectedSortable"></ul>

whit序列化

1 个答案:

答案 0 :(得分:0)

在php变量中获取整个结构。

$structure = "<li class='ui-state-default ui-sortable full w4-4'>
<div class='element-handler'>
<a href='#edit-element' class='edit revs-edit-element'>Edit</a>
<a href='#del' class='del-element delete'>X</a>
</div>
<div class='element'>
<span class='element-name'>Element name</span>
</div>
<textarea rows='6' cols='10' class='text-shortcode'>
[revs_flexslider page='home'] [shortcode page='home']
[shortcode page='home'][revs_shortcode page='home']
</textarea>
</li>";

然后运行sql查询

insert into table (structure) values ('$structure');

检索它只需使用select语句。

select * from table_name;

中的select输出
<ul id="contenitore" class="connectedSortable"><?php echo $select_output ?></ul>