Hi,
undzwar hab ich eine Drag und Drop funktion die ihren zustand in der mysql speichert.
Bisher funktoniert schonmal das Drag und Drop und das abspeichern in der mysql, der aktuellen sortierung.
Aber was muss ich machen um z.B. den include "whoisonline.php" in der index.php richtig anzuzeigen? Die Box ist zwar größer geworden aber hat den include nicht angezeigt .
[COLOR=Red]index.php[/COLOR]
[COLOR=Red]
db.php [/COLOR]
[COLOR=Red]
_stylesheet.css[/COLOR]
[COLOR=Red]
mysql
[/COLOR]
[COLOR=Red]
table[/COLOR]
mfg
undzwar hab ich eine Drag und Drop funktion die ihren zustand in der mysql speichert.
Bisher funktoniert schonmal das Drag und Drop und das abspeichern in der mysql, der aktuellen sortierung.
Aber was muss ich machen um z.B. den include "whoisonline.php" in der index.php richtig anzuzeigen? Die Box ist zwar größer geworden aber hat den include nicht angezeigt .
[COLOR=Red]index.php[/COLOR]
PHP-Code:
<?php
require('db.php');
$demo = new SortableExample();
$list = $demo->getList();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Drag and Drop</title>
<link href="_stylesheet.css" rel="stylesheet" type="text/css" />
<script src="lib/prototype.js"></script>
<script src="js/scriptaculous.js"></script>
<script>
Event.observe(window,'load',init,false);
function init() {
Sortable.create('listContainer',{tag:'div',onUpdate:updateList});
}
function updateList(container) {
var url = 'ajax.php';
var params = Sortable.serialize(container.id);
var ajax = new Ajax.Request(url,{
method: 'post',
parameters: params,
onLoading: function(){$('workingMsg').show()},
onLoaded: function(){$('workingMsg').hide()}
});
}
</script>
</head>
<body>
<div id="listContainer">
<?php
$string = array();
foreach($list as $item) {
?>
<div id="item_<?=$item['catid'];?>"><?=$item['category'];?>
<ul>
<li><?=$item['include'];?></li>
<li> </li>
</ul>
</div>
<?php
}
?>
</div>
</div>
</body>
</html>
db.php [/COLOR]
PHP-Code:
<?php
class SortableExample {
protected $conn;
protected $user = 'xxxxx';
protected $pass = 'xxxxx';
protected $dbname = 'xxxxx';
protected $host = 'xxxxxx';
public function __construct() {
$this->conn = mysql_connect($this->host, $this->user, $this->pass);
mysql_select_db($this->dbname,$this->conn);
}
public function getList() {
$sql = "SELECT * FROM categories ORDER BY orderid";
$recordSet = mysql_query($sql,$this->conn);
$results = array();
while($row = mysql_fetch_assoc($recordSet)) {
$results[] = $row;
}
return $results;
}
public function updateList($orderArray) {
$orderid = 1;
foreach($orderArray as $catid) {
$catid = (int) $catid;
$sql = "UPDATE categories SET orderid={$orderid} WHERE catid={$catid}";
$recordSet = mysql_query($sql,$this->conn);
$orderid++;
}
}
}
?>
_stylesheet.css[/COLOR]
PHP-Code:
/* DragDrop */
div#listContainer {
width: 170px;
float:left;
height: 100%;
}
div#listContainer div {
cursor: n-resize;
color:#FFF;
display: block;
width: 170px;
height: 100%;
padding-left: 10px;
padding-top: 10px;
}
div#listContainer ul {
cursor: default;
color:#000;
display: block;
list-style-type: none;
}
mysql
[/COLOR]
PHP-Code:
-- Tabellenstruktur für Tabelle `categories`
--
DROP TABLE IF EXISTS `categories`;
CREATE TABLE IF NOT EXISTS `categories` (
`catid` int(11) NOT NULL auto_increment,
`category` varchar(255) NOT NULL,
`include` varchar(200) NOT NULL,
`orderid` smallint(6) NOT NULL default '100',
PRIMARY KEY (`catid`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
--
-- Daten für Tabelle `categories`
--
INSERT INTO `categories` VALUES (1, 'Online', '<?php include("whoisonline.php"); ?>', 2);
INSERT INTO `categories` VALUES (2, 'shoutbox', '<?php include("shoutbox.php"); ?>', 4);
INSERT INTO `categories` VALUES (3, 'Teamspeak', '<?php include("teamspeak.php"); ?>', 1);
INSERT INTO `categories` VALUES (4, 'Besucher', '<?php include("stats.php"); ?>', 3);
table[/COLOR]
mfg
Kommentar