许愿墙—许下你的愿望

从网上找了一个很漂亮的许愿墙模板,早上就花了一段时间写了这个许愿墙程序,给大家分享下。
[img]http://www.thinkphp.cn/Uploads/editor/2015-05-27/556517bc7b938.jpg[/img]
首先我们遍历出所有的许愿列表:
$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 .= "<dl class='paper a" . $row['color'] . "'  style='left:" . $left . "px;top:" . $top . "px;z-index:" . $zindex . "' data-id=" . $row['id'] . ">  <dt><span class='username'>" . $row['name'] . "</span><span class='num'>" . $row['id'] . "</span></dt>  <dd class='content'>" . $row['content'] . "</dd>  <dd class='bottom'><span class='time'>" . tranTime($time) . "</span><a class='close' href='javascript:void(0);'></a></dd>  </dl>";

通过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";  }


[b]照片墙墙演示[/b]:[url]http://www.sucaihuo.com/php/136.html[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值