在用户选择选择选项后,我想弄清楚如何在 div 标签中显示表格,我快疯了。
jQuery/AJAX
$('#months').change(function() {
var month_sent = $('#months option:selected').text();
$.ajax ({
type: "GET",
dataType: 'text',
url: "db_connect.php",
data: "dept_sent=" + dept_sent + "&month_sent=" + month_sent + "&year_sent=" + year_sent,
success: function(data) {
$('#incident_table').html(data);
},
error: function() {
alert("Error!");
}
});
});
PHP
if ($dept && year && $month) {
$query = "SELECT date,dept,area_name,ticket,description,resolution FROM incidents WHERE (dept = '$dept') AND (YEAR(date) = '$year') AND (MONTH(date) = '$month')";
$query_image = "SELECT image_content FROM images WHERE dept_name = '$dept' AND year = '$year' AND month = '$month'";
$result = mysql_query($query);
$result_image = mysql_query($query_image);
while ($row = mysql_fetch_assoc($result)) {
// foreach ($row as $value) {
$incident .= '<tr><td>'.$row['date'].'</td><td>'.$row['dept'].'</td><td>'.$row['area_name'].'</td><td>'.$row['ticket'].'</td><td>'.$row['description'].'</td><td>'.$row['resolution'].'</td></tr>';
//}
}
echo $incident;
}
我需要做的就是能够在“事件” div 标签内显示表格
编辑:
<div style="border: 1px solid black; width:310px; height: 310px;" name="incidents" id="incidents">
<table id="incident_table">
</table>
</div>
请帮忙!:(