|
能帮我看看吗????
<?
include("./includes/connect.class.php");
include("./includes/html.php");
include("./zh_lang.php");
$conn=new myconn("localhost","guest","","mine");
$html=new html("日程管理");
$conn->connect_db();
$html->header();
global $rowcount,$row,$id_sql,$is_change;
$rowcount=0;
//$is_change=false;
// 建立数据库连接
// 获取当前页数
if( isset($_GET['page']) ){
$page = intval( $_GET['page'] );
}
else{
$page = 1;
}
// 每页数量
$page_size = 10;
// 获取总数据量
$sql = "select count(*) as amount from event";
$result =$conn->query($sql);
$row=$conn->data(0,0);
//$row = mysql_fetch_row($result);
$amount = $row;
//echo $amount;
// 记算总共有多少页
if( $amount ){
if( $amount < $page_size ){ $page_count = 1; } //如果总数据量小于$PageSize,那么只有一页
if( $amount % $page_size ){ //取总数据量除以每页数的余数
$page_count = (int)($amount / $page_size) + 1; //如果有余数,则页数等于总数据量除以每页数的结果取整再加一
}else{
$page_count = $amount / $page_size; //如果没有余数,则页数等于总数据量除以每页数的结果
}
}
else{
$page_count = 0;
}
// 翻页链接
$page_string = '';
if( $page == 1 ){
$page_string .= '第一页|上一页|';
}
else{
$page_string .= '<a href=?page=1>第一页</a>|<a href=?page='.($page-1).'>上一页</a>|';
}
if( ($page == $page_count) || ($page_count == 0) ){
$page_string .= '下一页|尾页';
}
else{
$page_string .= '<a href=index.php?page='.($page+1).'>下一页</a>|<a href=index.php?page='.$page_count.'>尾页</a>';
}
// 获取数据,以二维数组格式返回结果
if( $amount ){
$sql = "select id,priority,title,e_date,is_finish from event where is_finish=0 order by id limit ". ($page-1)*$page_size .", $page_size";
$result = $conn->query($sql);
$array=$conn->getarray();
}else{
$array = array();
}
?>
<form action=index.php?page=<?=$page?> method=post>
<table width="100%" cellspacing="0" cellpadding="10" border="0" align="center" >
<tr ><td class="bodyline" >
<table width="100%" cellspacing="0" cellpadding="1" border="0" align="center" >
<tr>
<td align="center" colspan="2" nowrap="nowrap"><span class="maintitle"><?=$top_title?></span></td>
</tr>
<tr>
<td align="right" ><span class="mainmenu"><a href="add.php" ><?=$add_thing?></a></span></td>
<td width="50" align="right" ><span class="mainmenu"><a href="" ><?=$un_finish?></a></span></td>
</tr>
</table>
<table width="100%" cellspacing="1" cellpadding="1" border="0" align="center" class=forumline>
<tr>
<th width="40" class="thTop" nowrap="nowrap">优先级</th>
<th width="440" class="thCornerL">要做的事情</th>
<th width="100" class="thCornerL" nowrap="nowrap">时间</th>
<th width="40" class="thCornerL">完成</th>
</tr>
<?
$id_array=array();
// if(isset($array))
// {
foreach($array as $key=>$val){
if($rowcount>1000)
$rowcount=0;
$rowcount++;
$row="row".($rowcount%2+1);
$id_array[]=$val[0];
//foreach($val as $key=>$val)
// {
?>
<tr>
<td class=<?=$row?> align="center" valign="middle" width="40"><span class="gen"><?
switch($val[1]){
case 0:
echo "高";
break;
case 1:
echo "中";
break;
case 2:
echo "低";
break;}
?></span></td>
<td class=<?=$row?> align="center" valign="middle" width="500"><span class="gensmall"><?=$val[2]?></span></td>
<td class=<?=$row?> align="center" valign="middle" width="40"><span class="data"><?=$val[3]?></span></td>
<td class=<?=$row?> align="center" valign="middle" width="40"><span class="name">
<?
echo "<input type=checkbox name=$val[0] >";
?>
</span></td>
</tr>
<?
// }
}
?>
<tr>
<td class="catBottom" colspan="4" align="center" height="28">
<input type="submit" tabindex="6" name="update" class="mainoption" value="Update"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="1" border="0" align="center" >
<tr ><td colspan="2" height=28 ><?=$page_string?></td></tr>
</table>
</td> </tr>
</table>
</form>
<?
if(isset($_POST['update']))
{
$sql="update event set is_finish=1 where ";
echo sizeof($id_array);
for($i=0;$i<sizeof($id_array);$i++)
{
if(isset($_POST[$id_array[$i]])){
$id_sql=$id_sql."id=".$id_array[$i]." or ";
$is_change=true;
}
}
echo "<br>";
echo $is_change;
if($is_change){
$sql=$sql. substr($id_sql,0,(strlen($id_sql)-3));
$conn->query($sql);
$is_change=false;
}
unset($id_array);
}
$html->footer();
?> |
|