拖拽删除PHP& jQuery的

时间:2014-03-06 13:50:00

标签: php jquery mysql

我在我正在开发的页面上使用了以下代码here,并且一切正常。

但是,我希望能够从我的数据库中提取多个列并将它们格式化为表格。

我已经尝试了一切,但无法让它发挥作用。我应该使用HTML表格还是其他东西?下面的代码只显示所有列作为一个长的未格式化的行。

<div id="container">

<div id="list">

<ul>

<?php
include("connect.php");
$query  = "SELECT id, listorder, description, owner, perc_complete, start_date, end_date FROM acct_project_details WHERE project_id='1' ORDER BY listorder ASC";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{

$id = stripslashes($row['id']);
$listorder = stripslashes($row['listorder']);
$text = stripslashes($row['description']);
$owner = stripslashes($row['owner']);
$perc_complete = stripslashes($row['perc_complete']);
$start_date = stripslashes($row['start_date']);
$end_date = stripslashes($row['end_date']);

?>

<li id="arrayorder_<?php echo $id ?>">


<?php echo $text; ?>
<?php echo $owner; ?>
<?php echo $perc_complete; ?>
<?php echo $start_date; ?>
<?php echo $end_date; ?>

<div class="clear"></div>
</li>

<?php } ?>

</ul>
</div>
</div>

非常感谢,

约翰

1 个答案:

答案 0 :(得分:0)

使用table tr tdTableDnD插件:

<!-- DOWNLOAD THESE SCRIPTS -->
<script type='text/javascript' src='http://isocra.com/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://isocra.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>
<script type='text/javascript' src='https://github.com/isocra/TableDnD/blob/master/stable/jquery.tablednd.js'></script>

<script type="text/javascript">
$(document).ready(function() {
    $("table.dnd").tableDnD();
});
</script>

<div id="container">

<div id="list">

<table class="dnd">

<?php
include("connect.php");
$query  = "SELECT id, listorder, description, owner, perc_complete, start_date, end_date FROM acct_project_details WHERE project_id='1' ORDER BY listorder ASC";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{

$id = stripslashes($row['id']);
$listorder = stripslashes($row['listorder']);
$text = stripslashes($row['description']);
$owner = stripslashes($row['owner']);
$perc_complete = stripslashes($row['perc_complete']);
$start_date = stripslashes($row['start_date']);
$end_date = stripslashes($row['end_date']);

?>

<tr id="arrayorder_<?php echo $id ?>">


<td><?php echo $text; ?></td>
<td><?php echo $owner; ?></td>
<td><?php echo $perc_complete; ?></td>
<td><?php echo $start_date; ?></td>
<td><?php echo $end_date; ?></td>

</tr>

<?php } ?>

</table>
</div>
</div>