php+dojo 的数据库保存拖动布局的一个方法dojo 这里下载
2015-01-24信息快讯网
<?php session_start(); if ($_SESSION['gh']==''){ header('location:login.php'); } include("config.php"); $sql="select * from module"; $result=mssql_query($sql,$conn); $num=mssql_num_rows($result); //echo $num; ?> <style type="text/css"> <!-- #container0 { border:1px dotted #990033; height: 10px; margin: 10px; } --> </style> <script type="text/javascript" src="include/dojo.js"></script> <script type="text/javascript"> //引用以下两个dojo包 dojo.require("dojo.style"); dojo.require("dojo.dnd.*"); function init(){ //利用classname取到元素列表,将其注册为dojo.dnd.HtmlDragSour var arr=dojo.html.getElementsByClass('divdrag') for(var i=0;i<arr.length;i++){ var parentDiv=arr.parentNode.id new dojo.dnd.HtmlDragSource(arr,parentDiv); } //定义容器 new dojo.dnd.HtmlDropTarget("container0", ["container0",<?php for ( $p = 1 ; $p <= $num ; $p ++) { echo '"'.'container'.$p.'"'; if ($p != $num){ echo ","; } } echo ']); '; for ($p =1 ; $p <=$num ;$p++){ echo chr(13).'new dojo.dnd.HtmlDropTarget("container'.$p.'", ["container0",'; for ($o =1 ;$o <= $num;$o++){ echo '"container'.$o.'"'; if ($o != $num){ echo ","; } } echo ']); '; } echo chr(13); ?> } //增加到window.onload事件中 window.onload=function(){init();} function bjsave() { gr="" <?php $sql='select id from module'; $result=mssql_query($sql,$conn); while($myrow=mssql_fetch_array($result)) echo 'if (mokuai'.$myrow['id'].'.parentElement.id !="container0") {'.chr(13).'gr=gr+'.$myrow['id'].'+"|"+ mokuai'.$myrow['id'].'.parentElement.id+ "$"'.chr(13).'}'.chr(13); ?> form1.gr.value=gr; form1.submit(); } </script> <div id="overDiv" STYLE="position:absolute; visibility:hide; z-index: 1;"></div> <div id="container0"> <?php $sql='select * from module where id not in (select mokuaiid from geren where gh ='.$_SESSION['gh'].')'; $result=mssql_query($sql,$conn); while($myrow=mssql_fetch_array($result)) echo '<span class="divdrag" id="mokuai'.$myrow['id'].'" style="border:1px dotted #990033;height: 20px;width:100px;margin: 5px; " title="'.$myrow['mmark'].'">'.$myrow['mn'].'</span>'; ?> </div> <table width="98%" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="150" valign="top"> <?php for ($p=1; $p<=$num;$p=$p+2){ echo '<div id="container'.$p.'" style="border:1px dotted #990033;height: 100px;margin: 10px; ">'; $sql='select mokuaiid from geren where biaogeid='.$p.' and gh ='.$_SESSION['gh']; $result=mssql_query($sql,$conn); while($myrow=mssql_fetch_array($result)){ $sql='select * from module where id='.$myrow['mokuaiid']; $result1=mssql_query($sql,$conn); while($myrow1=mssql_fetch_array($result1)){ echo '<span class="divdrag" id="mokuai'.$myrow1['id'].'" style="border:1px dotted #990033;height: 20px;width:100px;margin: 5px; " title="'.$myrow1['mmark'].'">'.$myrow1['mn'].'</span>'; } } echo '</div>'; } ?></td> <td width="150" valign="top"> <?php for ($p=2; $p<=$num;$p=$p+2){ echo '<div id="container'.$p.'" style="border:1px dotted #990033;height: 100px;margin: 10px; ">'; $sql='select mokuaiid from geren where biaogeid='.$p.' and gh ='.$_SESSION['gh']; $result=mssql_query($sql,$conn); while($myrow=mssql_fetch_array($result)){ $sql='select * from module where id='.$myrow['mokuaiid']; $result1=mssql_query($sql,$conn); while($myrow1=mssql_fetch_array($result1)){ echo '<span class="divdrag" id="mokuai'.$myrow1['id'].'" style="border:1px dotted #990033;height: 20px;width:100px;margin: 5px; " title="'.$myrow1['mmark'].'">'.$myrow1['mn'].'</span>'; } } echo '</div>'; } ?> </td> </tr> </table> <input type="button" name="Submit" value="保存布局" onclick="bjsave();" /> <form id="form1" name="form1" method="post" action="savegr.php"> <input name="gr" type="hidden" value="" /> </form>
<?php session_start(); if ($_SESSION['gh']==''){ header('location:login.php'); } include("config.php"); $sql='delete from geren where gh='.$_SESSION['gh']; mssql_query($sql); $gr=str_replace("container","",$_POST['gr']); //echo $gr; $array = explode("$", $gr); for ($i=0;$i<=count($array)-2;$i++){ $add=explode("|",$array[$i]); $sql='insert into geren (mokuaiid,biaogeid,gh) values ("'.$add[0].'","'.$add [1].'","'.$_SESSION['gh'].'")'; //echo $sql.'<br>'; mssql_query($sql); } header("location:view.php"); ?>
dojo 这里下载 http://download.dojotoolkit.org/release-0.3.1/dojo-0.3.1-ajax.zip
火车头discuz6.1 完美采集的php接口文件
PHP 分页类(模仿google)-面试题目解答
frename PHP 灵活文件命名函数 frename
PHPLog php 程序调试追踪工具
php 从数据库提取二进制图片的处理代码
封装一个PDO数据库操作类代码
php download.php实现代码 跳转到下载文件(response.redirect)
PHP PDO函数库(PDO Functions)第1/2页
php PDO中文乱码解决办法
php ignore_user_abort与register_shutdown_function 使用方法
php网页后退不再出现过期
php下实现农历日历的代码
用PHP 快速生成 Flash 动画的方法
使用php重新实现PHP脚本引擎内置函数
15种PHP Encoder的比较
可定制的PHP缩略图生成程式(需要GD库支持)
windows下PHP APACHE MYSQ完整配置
PHP中通过ADODB库实现调用Access数据库之修正版本 原创
PHP中通过ADO调用Access数据库的方法测试不通过
smarty+adodb+部分自定义类的php开发模式
adodb与adodb_lite之比较