从网上找了一个很漂亮的许愿墙模板,早上就花了一段时间写了这个许愿墙程序,给大家分享下。
首先我们遍历出所有的许愿列表:$query = mysql_query(select * from wishing_wall order by id desc limit 0, 50);
while ($row = mysql_fetch_array($query)) {
list($left, $top, $zindex) = explode('|', $row['xyz']);
$time = strtotime($row['addtime']);
$notes .=
. $row['name'] . . $row['id'] .
. $row['content'] .
. trantime($time) .
;接着我们把许愿列表放到.container里面:
通过jqueryui拖动许愿墙悬浮层代码如下:var zindex = 0;
function make_draggable(elements) {
elements.draggable({
handle: 'dt', //拖动把手
opacity: 0.8,
containment: 'parent', //拖动范围
start: function(e, ui) {
ui.helper.css('z-index', ++zindex)
},
stop: function(e, ui) {
$.get('ajax.php?act=update_position', {
x: ui.position.left,
y: ui.position.top,
z: zindex,
id: parseint(ui.helper.attr(data-id))
});
}
});
}php保存位置:$act = htmlspecialchars($_get['act']);
if ($act == 'update_position') {
if (!is_numeric($_get['id']) || !is_numeric($_get['x']) || !is_numeric($_get['y']) || !is_numeric($_get['z']))
die(0);
$id = intval($_get['id']);
$x = intval($_get['x']);
$y = intval($_get['y']);
$z = intval($_get['z']);
mysql_query(update wishing_wall set xyz=' . $x . | . $y . | . $z . ' where id= . $id);
echo 1;
}许愿墙演示:http://www.sucaihuo.com/php/136.html
许愿墙表单表情尚未做,请关注许愿墙代码后面的更新。
php+jquery+ajax漂亮的许愿墙效果.zip ( 239.97 kb 下载:137 次 )
ad:真正免费,域名+虚机+企业邮箱=0元