A Method for saving and dragging the layout of the php + dojo database is downloaded here.

Source: Internet
Author: User

I read the dojo framework introduced by the boss and learned to write it down. Please advise me when I first started learning php! Attachments cannot be sent. After sending two codes, you can understand them. Copy codeThe Code is as follows: <? 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">
// Reference the following two dojo packages
Dojo. require ("dojo. style ");
Dojo. require ("dojo. dnd .*");
Function init (){
// Use classname to retrieve the element List and register it as 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 );
}
// Define the container
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 ("iner '. $ p.'", ["container0 ",';
For ($ o = 1; $ o <= $ num; $ o ++ ){
Echo '"iner'. $ o .'"';
If ($ o! = $ Num ){
Echo ",";
}
}
Echo ']);';
}
Echo chr (13 );

?>
}
// Add to window. onload event
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>
& Lt; td width = "150" valign = "top" & gt;
<? Php
For ($ p = 1; $ p <= $ num; $ p = $ p + 2 ){
Echo '<div id = "iner'. $ 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>
& Lt; td width = "150" valign = "top" & gt;
<? Php
For ($ p = 2; $ p <= $ num; $ p = $ p + 2 ){
Echo '<div id = "iner'. $ 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 = "Save layout" onclick = "bjsave ();"/>
<Form id = "form1" name = "form1" method = "post" action = "savexhaust. php">
<Input name = "gr" type = "hidden" value = ""/>
</Form>Copy codeThe Code is as follows: <? 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 download http://download.dojotoolkit.org/release-0.3.1/dojo-0.3.1-ajax.zip here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.