拖放列PHP,JS,怎么办? [英] Drag and dropping columns PHP, JS, how can that be done?
本文介绍了拖放列PHP,JS,怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能够将行拖放到表中,但我对列很难。我的贝壳javascript似乎不工作。非常感谢任何帮助
<?php
pre>
if link = mysql_connect(localhost,root,)){
echo无法连接到db服务器;
}
elseif(!mysql_select_db(Disney)){
echo无法选择数据库;
}
else {
if(!$ rs = mysql_query(SELECT * FROM DisneyCharacters)){
echo无法解析查询;
}
elseif(mysql_num_rows($ rs)== 0){
echo未找到记录;
}
else {
//名称,电影,年份,ShoeSize,FavoriteColor,FavoriteFood,PhoneNumber,CharacterType,FavoriteDrink,Address,FavortieTvShow,School,Age,HouseSqFoot,RelationShip,Rating,CarModel ,CarYear,Boyfriend,
// NumberFriends,CriminalHistory,HappyEnding,FavoriteLocation,AppleDevice,WorkLocation,Weight,RepublicanDemocratic,DressColor,Shampoo,NumberKids)
echo< table width = \ 400\height = \1 \id = \sortedtable\class = \bordered\cellspacing = \0 \> \\\
echo< thead> \\\
< tr>;
echo< th> Name< / th>;
echo< th> Movie< / th>;
echo< th>年< / th>;
echo< th>鞋尺寸< / th>;
echo< th> Favorite Color< / th>;
echo< th> Favorite Food< / th>;
echo< th>电话号码< / th>;
echo< th>字元类型< / th>;
echo< th> Favorite Drink< / th>;
echo< th>地址< / th>;
echo< th> Favorite TvShow< / th>;
echo< th> School< / th>;
echo< th> Age< / th>;
echo< th> HouseSqFoot< / th>;
echo< th> Relationship< / th>;
echo< th> Rating< / th>;
echo< th> Car Model< / th>;
echo< th> Car Year< / th>;
echo< th>男朋友< / th>;
echo< th> Number Friends< / th>;
echo< th>犯罪历史< / th>;
echo< th> Happy Ending< / th>;
echo< th>收藏位置< / th>;
echo< th> Apple Device< / th>;
echo< th>工作地点< / th>;
echo< th> Weight< / th>;
echo< th>共和党民主党< / th>;
echo< th> Dress Color< / th>;
echo< th>洗发水< / th>;
echo< th> Number Kids< / th>;
echo< / tr> \\\
< / thead> \\\
;
echo< tbody>;
while($ row = mysql_fetch_array($ rs)){
echo< tr>
< td> $ row [Name]& nbsp< ; / td>
< td> $ row [Movie]& nbsp& nbsp< / td>
< td> $ row [Year]& nbsp< / td>
< td> $ row [ShoeSize]& nbsp< / td>
< td> $ row [FavoriteColor]& nbsp< / td>
< td> $ row [FavoriteFood]& ; nbsp< / td>
< td> $ row [PhoneNumber]& nbsp< / td>
< td> $ row [CharacterType]& nbsp< / td>
< td> $ row [FavoriteDrink]& nbsp< / td>
< td> $ row [Address]& nbsp< / td>
< td> $ row [FavoriteTvShow]& ; nbsp< / td>
< td> $ row [School]& nbsp< / td>
< td> $ row [Age]& nbsp< / td&
< td> $ row [HouseSqFoot]& nbsp< / td>
< td> $ row [RelationShip]& nbsp< / td>
< td> $ row [Rating]& nbsp< / td>
< td> $ row [CarModel]& nbsp< / td>
< td> $ row [CarYear]& nbsp< / td>
< td> $ row [男朋友]& nbsp< / td>
< td> $ row [NumberFriends]& nbsp< / td>
< td> $ row [CriminalHistory]& nbsp< / td>
< td> $ row [HappyEnding]& nbsp< / td>
< td> $ row [FavoriteLocation]& nbsp< / td>
< td> $ row [AppleDevice]& nbsp< / td>
< td> $ row [WorkLocation]& nbsp< / td>
< td> $ row [Weight]& nbsp< / td>
< td> $ row [RepublicanDemocratic]& nbsp< / td>
< td> $ row [DressColor]& nbsp< / td>
< td> $ row [Shampoo]& nbsp< / td>
< td> $ row [NumberKids]& nbsp< / td>
< / tr> \\\
;
}
echo< / tbody>;
echo < / table>< br /> \\\
;
}
}
?>
/// JavaScript
$(document).ready(function(){
$(#sortedtable)。tablesorter({
sortList:[
[0,0],
[2,1]
],
widgets:['zebra']
});
$(tbody)。sortable();
$ (tbody)。disableSelection();
});
//拖放列
$(document).ready
$(#sortedtable)。tablesorter({
sortList:[
[0,0],
[2,1]
],
widgets:['zebra']
});
$(thead)。sortable();
$(thead)。disableSelection();
} );
解决方案可以使用库DataTables。它提供了比你更多的要求,但易于使用和高度可配置
I was able to get the rows to be drag and dropped within the table, but I am having difficulty with the columns. My bellow javascript doesn't seem to work. Any help will be greatly appreciated
<?php if(!$link = mysql_connect("localhost", "root", "")) { echo "Cannot connect to db server"; } elseif(!mysql_select_db("Disney")) { echo "Cannot select database"; } else { if(!$rs = mysql_query("SELECT * FROM DisneyCharacters")) { echo "Cannot parse query"; } elseif(mysql_num_rows($rs) == 0) { echo "No records found"; } else { // Name, Movie, year, ShoeSize, FavoriteColor, FavoriteFood, PhoneNumber, CharacterType, FavoriteDrink, Address, FavortieTvShow, School, Age, HouseSqFoot, RelationShip, Rating, CarModel, CarYear, Boyfriend, // NumberFriends, CriminalHistory, HappyEnding, FavoriteLocation, AppleDevice, WorkLocation, Weight, RepublicanDemocratic, DressColor, Shampoo, NumberKids) echo "<table width=\"400\" height=\"1\" id=\"sortedtable\" class=\"bordered\" cellspacing=\"0\">\n"; echo "<thead>\n<tr>"; echo "<th>Name </th>"; echo "<th>Movie </th>"; echo "<th>Year </th>"; echo "<th>Shoe Size </th>"; echo "<th>Favorite Color </th>"; echo "<th>Favorite Food </th>"; echo "<th>Phone Number </th>"; echo "<th>Character Type </th>"; echo "<th>Favorite Drink </th>"; echo "<th>Address </th>"; echo "<th>Favorite TvShow </th>"; echo "<th>School </th>"; echo "<th>Age </th>"; echo "<th>HouseSqFoot </th>"; echo "<th>Relationship </th>"; echo "<th>Rating </th>"; echo "<th>Car Model </th>"; echo "<th>Car Year </th>"; echo "<th>Boyfriend </th>"; echo "<th>Number Friends </th>"; echo "<th>Criminal History </th>"; echo "<th>Happy Ending </th>"; echo "<th>Favorite Location </th>"; echo "<th>Apple Device </th>"; echo "<th>Work Location </th>"; echo "<th>Weight</th>"; echo "<th>Republican Democratic </th>"; echo "<th>Dress Color </th>"; echo "<th>Shampoo </th>"; echo "<th>Number Kids </th>"; echo "</tr>\n</thead>\n"; echo " <tbody>"; while($row = mysql_fetch_array($rs)) { echo "<tr> <td>$row[Name] </td> <td>$row[Movie]  </td> <td>$row[Year] </td> <td>$row[ShoeSize] </td> <td>$row[FavoriteColor] </td> <td>$row[FavoriteFood] </td> <td>$row[PhoneNumber] </td> <td>$row[CharacterType] </td> <td>$row[FavoriteDrink] </td> <td>$row[Address] </td> <td>$row[FavoriteTvShow] </td> <td>$row[School] </td> <td>$row[Age] </td> <td>$row[HouseSqFoot] </td> <td>$row[RelationShip] </td> <td>$row[Rating] </td> <td>$row[CarModel] </td> <td>$row[CarYear] </td> <td>$row[Boyfriend] </td> <td>$row[NumberFriends] </td> <td>$row[CriminalHistory] </td> <td>$row[HappyEnding] </td> <td>$row[FavoriteLocation] </td> <td>$row[AppleDevice] </td> <td>$row[WorkLocation] </td> <td>$row[Weight] </td> <td>$row[RepublicanDemocratic] </td> <td>$row[DressColor] </td> <td>$row[Shampoo] </td> <td>$row[NumberKids] </td> </tr>\n"; } echo " </tbody>"; echo "</table><br />\n"; } } ?>
///JavaScript
// Drag and drop rows $(document).ready(function () { $("#sortedtable").tablesorter({ sortList: [ [0, 0], [2, 1] ], widgets: ['zebra'] }); $("tbody").sortable(); $("tbody").disableSelection(); }); //Drag and drop columns $(document).ready(function () { $("#sortedtable").tablesorter({ sortList: [ [0, 0], [2, 1] ], widgets: ['zebra'] }); $("thead").sortable(); $("thead").disableSelection(); });
解决方案You can use the library DataTables. It provides a lot more than you ask but is easy to use and highly configurable
这篇关于拖放列PHP,JS,怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文