第一个问题:
当用户删除特定行时,我需要使用ajax删除该行而不刷新页面。我该如何做?
第二个问题:
实际上,我正在计算从某天到前7天的页面访问次数。 但是,我希望在今天访问页面时,检索上一周的记录 也就是从星期天(2011年11月20日)到星期六(2011年11月26日) 当下周一访问页面时,我要检索这周的记录 也就是从星期天(2011年11月27日)到星期六(2011年12月3日)function authenticate(){
$.ajax({
type: "POST",
url: "authentication.php",
data: $("#login_form").serialize(),
success: function(msg){
if(msg==1){
$('#delete').html("success"); //if success message appear only i have to remove particular row
})
}else{
$('#delete').html("error");
}
},
error:function(msg){
alert(msg);
$('#delete').dialog("close");
}
});
}
<div style='display: none;' id='delete'></div>
<table border="1">
<tr>
<th>Title</th>
<th>Public Id</th>
<th>Pass</th>
<th></th>
</tr>
<?php
$select = $db->select ()
->from ( 'test', '*' )
->where ( 'user_id = ?', 1 )
->where ( 'test.created > DATE_SUB(CURDATE(), INTERVAL 7 DAY)' );
$tourDetails = $db->fetchAll ( $select );
$i = 0;
foreach ( $tourDetails as $row1 ) {
$i ++;
$title = $row1 ['title'];
$PublicId = $row1 ['public_id'];
if (($i % 2) == 0 ) {
$rowResponse = prepareRow ( true, $title, $PublicId);
echo $rowResponse;
} else {
$rowResponse = prepareRow ( false, $title, $PublicId);
echo $rowResponse;
}
}
function prepareRow($flag, $title, $PublicId) {
$rowResponse = "";
if ($flag) {
$rowResponse .= '<tr class="even">';
} else {
$rowResponse .= '<tr class="odd" >';
}
$rowResponse .= '
<td> ' . $title . ' </td>
<td> ' . $publicId . ' </td>
<td><p><a onclick=openDialog("'. $PublicId .'","delete") href="#" id="dialog_link">
Delete </a></p>
</td>';
return $rowResponse;
?>
</table>