所以我有两个页面正在使用php创建一个html表:
$Trainee_HTML = "<div id=\"container\"><table class=\"display\" id=master_table>";
$Trainee_HTML .= "<thead>";
$Trainee_HTML .= "<tr>";
$Trainee_HTML .= "<th> Enabled </th>";
$Trainee_HTML .= "<th> Name </th>";
$Trainee_HTML .= "<th> Email </th>";
$Trainee_HTML .= "<th> EID </th>";
$Trainee_HTML .= "<th> Spriden </th>";
$Trainee_HTML .= "<th> Active </th>";
$Trainee_HTML .= "<th> Source </th>";
$Trainee_HTML .= "<th> Date Inserted </th>";
$Trainee_HTML .= "<th> Next Contact </th>";
$Trainee_HTML .= "<th> Completion Status </th>";
$Trainee_HTML .= "<th> Completion Date </th>";
$Trainee_HTML .= "<th> Curriculum </th>";
$Trainee_HTML .= "<th> Group </th>";
$Trainee_HTML .= "<th> Stage </th>";
$Trainee_HTML .= "<th> Comments </th>";
$Trainee_HTML .= "<th> Comment Date </th>";
$Trainee_HTML .= "</tr>";
$Trainee_HTML .= "</thead>";
$Trainee_HTML .= "<tbody col = ".$num.">";
.....在这里填写数据
$string = "COM";
$text = 'text';
$post = 'get';
$testphp="update_user.php";
$sub = "submit";
$user = "user";
$hidden = "hidden";
$name1 = "submit1";
$ename = "email";
$enab = "enabled";
$Trainee_HTML .= "<tr>";
$Trainee_HTML .= "<form method = ".$post." action = ".$testphp."><td>". $id ."<br>".
$edit_link. "</td>";
$Trainee_HTML .= "<td><center>". $enabled_img ."</center></td>";
$Trainee_HTML .= "<td>". $name. "</td>";
$Trainee_HTML .= "<td>". $email. "</td>";
$Trainee_HTML .= "<td>". $eid. "</td>";
$Trainee_HTML .= "<td>". $spriden. "</td>";
$Trainee_HTML .= "<td>". $active. "</td>";
$Trainee_HTML .= "<td>". $source. "</td>";
$Trainee_HTML .= "<td>". $date_inserted. "</td>";
$Trainee_HTML .= "<td>". $next_contact. "</td>";
$Trainee_HTML .= "<td>". $compstatus. "</td>";
$Trainee_HTML .= "<td>". $compdate. "</td>";
$Trainee_HTML .= "<td>". $curriculum. "</td>";
$Trainee_HTML .= "<td>". $group. "</td>";
$Trainee_HTML .= "<td>". $stage. "</td>";
$Trainee_HTML .= "<td><input type=".$text." name=".$string." ><br><input type=".$sub." name =".$name1."></td>";
$Trainee_HTML .= "<td>". $date. "</td>";//added as above
$Trainee_HTML .= "<input type=".$hidden." name = ".$enab." value = ".$enabled.">";
$Trainee_HTML .= "<input type=".$hidden." name = ".$ename." value = ".$email."> </form>";
$Trainee_HTML .= "</tr>";
}
// close table
$Trainee_HTML .= "</tbody>";
$Trainee_HTML .= "</table> </div><br /><br />";
这是我使用jquery创建表的地方。
<script type="text/javascript" language="javascript" src="./media/js/jquery.js"> </script>
<script type="text/javascript" language="javascript" src="./media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" src="./media/js/ZeroClipboard.js"></script>
<script type="text/javascript" charset="utf-8" src="./media/js/TableTools.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {
$('#master_table').dataTable( {
"aaSorting": [[ 2, "asc" ]],
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": false,
"bJQueryUI": true,
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"aButtons": [
"copy", "csv", "xls"
]
}
} );
} );
</script>
我知道错误来自这一行
"oTableTools": {
"aButtons": [
"copy", "csv", "xls"
]
但我对jquery不是很了解(我几乎一无所知) 我已经检查了网站上的其他答案,但这些答案都没有帮助我解决方案,所以这就是为什么我的问题不同。我有一个页面在前一页使用相同的确切代码,但该页面使用我的整个数据库(大约400个条目),这个页面更像是一个'编辑'页面所以它只有一个条目。任何帮助将不胜感激,因为这是工作,我不知道我在做什么。
修改
这是我的数据库抓取。数据库加载正常没有任何问题 在session_start(); $ conn = mysql_connect($ db_server,$ db_username,$ db_password)或die('连接到mysql时出错'); mysql_select_db($ DB_NAME);
$date = date('Y-m-d');//the date from the system, created as a date stamp for the user.
$trainee_id = (!isset($_GET['id']))? "-1" : $_GET['id'];
// Select Trainees in main table
//
$Trainee_query = "Select t.id, t.enabled, t.name, t.email, t.eid, t.spriden, t.active, t.source, t.date_trainee_inserted, ".
"t.completion_status, t.completion_date, t.curriculum, ".
"t.group_name, t.stage, t.next_contact_email ".
"From ". $Main_Trainees_Tbl. " t ".
"Where t.id = ". $trainee_id. " ";
$result = mysql_query($Trainee_query) or die(mysql_error());