在好例子网,分享、交流、成长!
您当前所在位置:首页PHP 开发实例PHP语言基础 → <赞>php记账本(入门级示例)源码

<赞>php记账本(入门级示例)源码

PHP语言基础

下载此实例
  • 开发语言:PHP
  • 实例大小:0.25M
  • 下载次数:109
  • 浏览次数:1254
  • 发布时间:2018-12-10
  • 实例类别:PHP语言基础
  • 发 布 人:cnzp521
  • 文件格式:.zip
  • 所需积分:2
 相关标签: php 入门 记账

实例介绍

【实例简介】

0. 在你的mysql数据库创建 jizhangdb 数据库

1. 修改 config.php中的数据库连接信息为你本地mysql数据库的

2. 在浏览器运行 install.php页面 即可安装成功数据库

3. 在浏览器访问 index.php页面即可看到效果

from clipboard

from clipboard

【实例截图】

from clipboard


from clipboard


from clipboard


from clipboard


from clipboard


from clipboard


from clipboard

【核心代码】

<?php
include_once("header.php");
?>
<script type="text/javascript">
    var checkall = document.getElementsByName("del_id[]");
    function select() {
        //全选
        for (var $i = 0; $i < checkall.length; $i  ) {
            checkall[$i].checked = true;
        }
    }
    function fanselect() {
        //反选
        for (var $i = 0; $i < checkall.length; $i  ) {
            if (checkall[$i].checked) {
                checkall[$i].checked = false;
            } else {
                checkall[$i].checked = true;
            }
        }
    }
    function noselect() {
        //全不选
        for (var $i = 0; $i < checkall.length; $i  ) {
            checkall[$i].checked = false;
        }
    }

</script>

<script>
    window.onload = function() {
        var oTxt1 = document.getElementById('zhuan');
        var oBtn1 = document.getElementById('zhuan1');
        oBtn1.onclick = function() {
            location.href = "edit.php?p=" oTxt1.value "";
        }
    }
</script>


<!-- 记住选择页js <script language="javascript" type="text/javascript">
    function save() {
        selectIndex = document.getElementById("tiao").selectedIndex;
        document.cookie = 'selectIndex ='   selectIndex;
    }
    window.onload = function () {
        var cooki = document.cookie;
        if (cooki != "") {
            cooki = "{\""   cooki   "\"}";
            cooki = cooki.replace(/\s*/g, "").replace(/=/g, '":"').replace(/;/g, '","');
            var json = eval("("   cooki   ")"); //将coolies转成json对象
            document.getElementById("tiao").options[json.selectIndex].selected = true;
        }
        else
            save();
    }
</script> -->


<?php

if ($_GET[ok]) {

    //针对$ok被激活后的处理:
    $shij = strtotime("$_GET[shijian]");
    $sql = "update ".$qianzui."account set acmoney='".$_GET[jine]."',acremark='".$_GET[beizhu]."',actime='".$shij."' where acid='".$_GET[id]."' and jiid='".$_SESSION[uid]."'";
    $result = mysql_query($sql);
    if ($result)
        echo("<script type='text/javascript'>alert('修改成功!');history.go(-2);</script>");
    else
        echo("<script type='text/javascript'>alert('修改失败!');history.go(-2);</script>");

} else {
    if ($_GET[id]) {
        $sql = "select * from ".$qianzui."account where acid='".$_GET[id]."' and jiid='".$_SESSION[uid]."'";
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result);

        $sql2 = "select * from ".$qianzui."account_class where classid= '".$row[acclassid]."' and ufid='".$_SESSION[uid]."'";
        $classquery = mysql_query($sql2);
        $classinfo = mysql_fetch_array($classquery);


        echo "<table align='left' width='100%' border='0' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3' class='table table-striped table-bordered'>
      <tr>
        <td bgcolor='#EBEBEB'> 账目修改</td>
      </tr>
      <tr>
        <td bgcolor='#FFFFFF'>
   <form method=get action=''>
<INPUT TYPE='hidden' name='id' value=".$row[acid].">
金额:<input type=text name='jine' value=".$row[acmoney]."><br /><br />
账目分类:".$classinfo[classname]."<br /><br />
收入/支出:";
        if ($classinfo[classtype] == 1) {
            echo '收入';
            $income = $income $row[acmoney];
        } else {
            echo '支出';
            $spending = $spending $row[acmoney];
        }

        echo "<br /><br />
时间:<input rows='1' cols='20' name='shijian' class='sang_Calender' value='".date('Y-m-d H:i',$row[actime])."'> <br /><br />
备注:<input type=text name='beizhu' value=".$row[acremark]."><br /><br />
 <input type=submit name=ok value='提交' class='btn btn-default'>
   </form>		</td>
      </tr>
    </table>";

    }

}
?>


<?php

if ($_POST[Submit]) {
    echo "";
} else {
    if ($conn) {
        mysql_select_db("jizhang");
        if (!$_GET[id]) {
            //$result = mysql_query("select * from jizhang");

            //每页显示的数
            $pagesize = 10;

            //确定页数 p 参数
            $p = $_GET['p']?$_GET['p']:1;

            //数据指针
            $offset = ($p-1)*$pagesize;

            //查询本页显示的数据
            $query_sql = "SELECT * FROM ".$qianzui."account where jiid='$_SESSION[uid]' ORDER BY actime DESC LIMIT  $offset , $pagesize";

            $query = mysql_query($query_sql);


            //echo $query_sql;

            echo "<table width='100%' border='0' align='left' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3' class='table table-striped table-bordered'>
                <tr>
                <th bgcolor='#EBEBEB'>账目</th>
                <th bgcolor='#EBEBEB'>收支</th>
                <th bgcolor='#EBEBEB'>金额</th>
                <th bgcolor='#EBEBEB'>时间</th>
                <th bgcolor='#EBEBEB'>备注</th>
                <th bgcolor='#EBEBEB'><form action='delete.php' method='post'><a href='javascript:select()'>全选</a> | <a href='javascript:fanselect()'>反选</a> | <a href='javascript:noselect()'>不选</a> <input type='submit' name='delete' value='删除'/></th>
                </tr>";

            if ($result === FALSE) {
                die(mysql_error());
                // TODO: better error handling
            }

            while ($row = mysql_fetch_array($query)) {
                $sql = "select * from ".$qianzui."account_class where classid= $row[acclassid] and ufid='$_SESSION[uid]'";
                $classquery = mysql_query($sql);
                $classinfo = mysql_fetch_array($classquery);
                echo "<tr>";
                if ($classinfo[classtype] == 1) {
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>" . $classinfo['classname'] . "</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>" . $row['acmoney'] . "</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>收入</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>".date("Y-m-d",$row[actime])."</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>". $row[acremark] ."</font></td>";
                } else {
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='red'>" . $classinfo['classname'] . "</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='red'>" . $row['acmoney'] . "</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='red'>支出</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='red'>".date("Y-m-d",$row[actime])."</font></td>";
                    echo "<td align='left' bgcolor='#FFFFFF'><font color='red'>". $row[acremark] ."</font></td>";
                }
                echo "<td align='left' bgcolor='#FFFFFF'><a href=edit.php?id=".$row['acid'].">编辑</a> <a href=delete.php?id=".$row['acid'].">删除</a>
				<input name='del_id[]' type='checkbox' id='del_id[]' value=".$row['acid']." /></td>";
                echo "</tr>";
            }
            echo "</table>";


            echo "<table width='100%' border='0' align='left' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3' class='table table-striped table-bordered'>
                <tr><td align='left' width='100%' bgcolor='#FFFFFF'>";
            //分页代码
            //计算总数
            $count_result = mysql_query("SELECT count(*) as count FROM ".$qianzui."account where jiid='$_SESSION[uid]'");
            $count_array = mysql_fetch_array($count_result);

            //计算总的页数
            $pagenum = ceil($count_array['count']/$pagesize);
            echo "<ul class='pagination'>";
            echo '<li class="disabled"><a href="#">共',$count_array['count'],'条 <span id="total" style="display:none">',$pagenum,'</span></a></li>';
            //后面共几页

            if ($pagenum > 1) {
                for ($i = 1;$i < $pagenum;$i  ) {
                    if ($i == $p) {
                        echo "<span id='pagingText' style='display:none'>$i</span>";
                    }
                }
            }

            /* echo "<select name='tiao' id='tiao' style='height:18px' onchange='self.location.href=options[selectedIndex].value;onchange=save()'>";
echo "<option value='edit.php?p=1'>跳转</option>";
if ($pagenum > 1) {
    for($i=1;$i<=$pagenum;$i  ) {
            echo "<option value='edit.php?p=$i'>$i</option>";
    }
}
echo "</select>"; */

            //循环输出各页数目及连接	echo ' <a href="edit.php?p=',$i-1,'">上一页</a>';

            //echo " <li><a href='edit.php?p=1'>首页</a></li>";
            //echo "<li><a href='edit.php?p=$pagenum'>尾页</a></li>";
            if ($pagenum > 1) {
                for ($i = 1;$i <= $pagenum;$i  ) {
                    if ($i == $p) {
                        if ($i != 1) {
                            echo '<li><a href="edit.php?p=',$i-1,'">&laquo;</a></li>';
                        }
                    }
                }
            }

            if ($pagenum > 1) {
                for ($i = 1;$i < $pagenum;$i  ) {
                    if ($i == $p) {
                        echo '<li><a href="edit.php?p=',$i 1,'">&raquo;</a></li>';
                    }
                }
            }

            echo "</ul>";
            echo "<ul class='pagination' id='pagingDiv'><ul/>";
            echo "</td>";
            // echo "<td align='right' width='10%' bgcolor='#FFFFFF'><input type='text' name='zhuan' id='zhuan' style='width:35px'/> <input type='submit' name='go' id='go' value='go' /></td>"; //跳转页面


            echo "</form>";
            echo "</table>";
            /*echo "<table width='100%' border='0' align='left' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3' class='table table-striped table-bordered'>";
		echo "<tr><td align='left' bgcolor='#FFFFFF'><ul class='pagination' id='pagingDiv'><ul/></td></tr>";
		echo "</table>"; */


        }

    }
    //显示列表的内容

}
?>

<script language="javascript">
    //首先获取当前的总页数,一般是后台传递过来的,这里假定40页。
    var total = document.getElementById("total").innerHTML;
    //id="pagingDiv"的div通过pagingConstruct函数构造,比如加载网页是第1页的
    var url = window.location.href;
    var index =  url.substring(url.lastIndexOf('=')   1);
    if (index > 0) {
        pagingConstruct(index);
    } else {
        pagingConstruct(1);
    }

    //形式参数paging是指当前页
    function pagingConstruct(paging) {
        //先更新一下行内文本
        document.getElementById("pagingText").innerHTML = paging;
        var pagingDivInnerHTML = "";
        //这里是加载省略号的flag
        var isHiddenExist = 0;
        //从第1页读到第40页。
        for (var i = 1; i <= total; i  ) {
            //如果读到当前页,就仅仅加载一个文本,不放链接
            if (i == paging) {
                pagingDivInnerHTML  = "<li class='active'><a href='#'>"   i   "</a></li>";
            } else {
                //如果是页首,中间页,页尾,当前页的前后三页则不省略。
                //if (i < 4 || i < (paging   3) && i > (paging - 3)|| i > (total / 2 - 2) && i < (total / 2   2) || i > (total - 1)) {
                if (i < 2 || i < (paging   4) && i > (paging - 4) || i > (total - 1)) {
                    pagingDivInnerHTML  = "<li><a href='edit.php?p="   i   "' onclick='pagingConstruct("   i   ")'>"   i   "</a></li>";
                    isHiddenExist = 0;
                }
                //否则就构造...
                else {
                    if (isHiddenExist == 0) {
                        pagingDivInnerHTML  = ""; //引号里面放这个<li><a href='#'>...</a></li>显示...
                        isHiddenExist = 1;
                    }
                }
            }
        }
        //把构造的内容放上去pagingDiv
        document.getElementById("pagingDiv").innerHTML = pagingDivInnerHTML;
    }
</script>

<table align="left" width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor='#B3B3B3' class='table table-striped table-bordered'>
    <tr>
        <td bgcolor="#EBEBEB"> 查询修改</td>
    </tr>
    <tr>
        <td bgcolor="#FFFFFF">
            <form id="form1" name="form1" method="post" action="">
                选择分类:
                <select name="classid" id="classid" style="height:26px;">
                    <option value="quan">全部分类</option>
                    <option value="sr">收入--</option>
                    <?php
                    $sqlshouru = "select * from ".$qianzui."account_class where ufid='$_SESSION[uid]' and classtype='1'";
                    $queryshouru = mysql_query($sqlshouru);
                    while ($rowshouru = mysql_fetch_array($queryshouru)) {
                        echo "<option value='$rowshouru[classid]'>------$rowshouru[classname]</option>";
                    }
                    ?>
                    <option value="zc">支出--</option>
                    <?php
                    $sqlzhichu = "select * from ".$qianzui."account_class where ufid='$_SESSION[uid]' and classtype='2'";
                    $queryzhichu = mysql_query($sqlzhichu);
                    while ($rowzhichu = mysql_fetch_array($queryzhichu)) {
                        echo "<option value='$rowzhichu[classid]'>------$rowzhichu[classname]</option>";
                    }
                    ?>
                </select><br /><br />
                日期:从 <input type="date" name="time1" id="time1" style="height:26px;width:115px;" /> 到 <input type="date" name="time2" id="time2" style="height:23px;width:115px;" />
                <br /><br />
                备注:<input type="text" name="beizhu" id="beizhu" /> 留空则输出全部,或输入金额范围格式:1-100,支持小数点。<br /><br />

                <input type="submit" name="Submit" value="查询" class="btn btn-default" /><br /><br />
                <input type="submit" name="Submitfanwei" value="点这里查询金额范围" class="btn btn-default" /><br /><br />

            </form>
        </td>
    </tr>

</table>


<?php if ($_POST[Submit]) {
    $a = "%";
    $b = $_POST[beizhu];
    $c = $a.$b.$a;
    //只查询备注
    if ($_POST[classid] == "quan" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {

        $sql = "select * from ".$qianzui."account where acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";
    }
    //什么都没填
    if ($_POST[classid] == "quan" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {
        $sql = "select * from ".$qianzui."account where jiid='$_SESSION[uid]' ORDER BY actime ASC";
    }
    //只查询分类
    if ($_POST[classid]<>"quan" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {
        $sqlclassid = "acclassid=".$_POST[classid];
        $sql = "select * from ".$qianzui."account where ".$sqlclassid." and jiid='$_SESSION[uid]' ORDER BY actime ASC";
    }

    //只查询分类收
    if ($_POST[classid] == "zc" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {

        $sql = "select * from ".$qianzui."account where zhifu='2' and jiid='$_SESSION[uid]' ORDER BY actime ASC";
    }
    if ($_POST[classid] == "sr" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {

        $sql = "select * from ".$qianzui."account where zhifu='1' and jiid='$_SESSION[uid]' ORDER BY actime ASC";
    }
    //只查询分类支

    //只查询日期
    if ($_POST[classid] == "quan" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {

        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");
        $sql = "select * from ".$qianzui."account where ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }
    if ($_POST[classid] == "quan" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {

        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");
        $sql = "select * from ".$qianzui."account where ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }
    //------------------------------
    //查询分类,日期,备注
    if ($_POST[classid]<>"" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {

        $sqlclassid = "acclassid=".$_POST[classid];
        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

        $sql = "select * from ".$qianzui."account where ".$sqlclassid." and ".$sqltime." and acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }
    //----------------------------------------
    //查询收支,备注
    if ($_POST[classid] == "sr" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {
        $type = "1";


        $sql = "select * from ".$qianzui."account where zhifu='$type' and acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }
    if ($_POST[classid] == "zc" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {
        $type = "2";


        $sql = "select * from ".$qianzui."account where zhifu='$type' and acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }

    //查询收支,日期
    if ($_POST[classid] == "sr" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {
        $type = "1";

        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

        $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }
    if ($_POST[classid] == "zc" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {
        $type = "2";

        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

        $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }
    //查询收支,日期,备注
    if ($_POST[classid] == "sr" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {
        $type = "1";

        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

        $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }
    if ($_POST[classid] == "zc" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {
        $type = "2";


        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

        $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }

    //查询日期,备注
    if ($_POST[classid] == "quan" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {

        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

        $sql = "select * from ".$qianzui."account where ".$sqltime." and acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }


    //--------------------------------------
    //查询分类,备注
    if ($_POST[classid]<>"quan" && $_POST[classid]<>"sr" && $_POST[classid]<>"zc" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {

        $sqlclassid = "acclassid=".$_POST[classid];

        $sql = "select * from ".$qianzui."account where ".$sqlclassid." and acremark like '$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }

    //查询分类,日期
    if ($_POST[classid]<>"quan" && $_POST[classid]<>"sr" && $_POST[classid]<>"zc" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {

        $sqlclassid = "acclassid=".$_POST[classid];
        $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

        $sql = "select * from ".$qianzui."account where ".$sqlclassid." and ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

    }


    echo "
				<table align='left' width='100%' height='20' border='0' align='left' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3' class='table table-striped table-bordered'>
  <tr>
  <td align='left' bgcolor='#EBEBEB'> 查询结果&nbsp;<font id='stat'></font></td>
  </tr>
</table>
<form action='delete.php' method='post'>
 <table id='excel' class='table table-striped' width='100%' border='0' align='left' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3'>
                <tr>
                <th bgcolor='#EBEBEB'>分类</th>
                <th bgcolor='#EBEBEB'>金额</th>
                <th bgcolor='#EBEBEB'>收支</th>
                <th bgcolor='#EBEBEB'>时间</th>
                <th bgcolor='#EBEBEB'>备注</th>
				<th bgcolor='#EBEBEB'><a href='javascript:select()'>全选</a> | <a href='javascript:fanselect()'>反选</a> | <a href='javascript:noselect()'>不选</a> <input type='submit' name='delete' value='删除'/></th>
                </tr>
				";


    $query = mysql_query($sql);
    while ($row = mysql_fetch_array($query)) {
        $sql = "select * from ".$qianzui."account_class where classid= $row[acclassid] and ufid='$_SESSION[uid]'";
        $classquery = mysql_query($sql);
        $classinfo = mysql_fetch_array($classquery);
        echo "<tr>";
        if ($classinfo[classtype] == 1) {
            echo "<td align='left' class='xl26' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>" . $classinfo['classname'] . "</font></td>";
            echo "<td align='left' class='xl29' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>" . $row['acmoney'] . "</font></td>";
            echo "<td align='left' class='xl27' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>收入</font></td>";
            echo "<td align='left' class='xl30' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>".date("Y-m-d",$row[actime])."</font></td>";
            echo "<td align='left' class='xl28' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>". $row[acremark] ."</font></td>";
            $income = $income $row[acmoney];
        } else {
            echo "<td align='left' class='xl26' bgcolor='#FFFFFF'><font color='red'>" . $classinfo['classname'] . "</font></td>";
            echo "<td align='left' class='xl29' bgcolor='#FFFFFF'><font color='red'>" . $row['acmoney'] . "</font></td>";
            echo "<td align='left' class='xl27' bgcolor='#FFFFFF'><font color='red'>支出</font></td>";
            echo "<td align='left' class='xl30' bgcolor='#FFFFFF'><font color='red'>".date("Y-m-d",$row[actime])."</font></td>";
            echo "<td align='left' class='xl28' bgcolor='#FFFFFF'><font color='red'>". $row[acremark] ."</font></td>";
            $spending = $spending $row[acmoney];
        }
        echo "<td align='left' bgcolor='#FFFFFF'><a href=edit.php?id=".$row['acid'].">编辑</a> <a href=delete.php?id=".$row['acid'].">删除</a>
				<input name='del_id[]' type='checkbox' id='del_id[]' value=".$row['acid']." /></td>";
        echo "</tr>";
    }
    echo "</table></form>
				";


}
?>

<?php if ($_POST[Submitfanwei]) {
    if ($_POST[beizhu]<>"") {
        $b = $_POST[beizhu];
        $str = trim($b);
        if (empty($str)) {
            return '';
        }
        $temp = array('1','2','3','4','5','6','7','8','9','0','.');
        $mumList = array();
        $result = '';
        $maxNum = 0;
        for ($i = 0;$i < strlen($str);$i  ) {
            if (in_array($str[$i],$temp)) {

                if (is_numeric($str[$i])) {
                    $result.= $str[$i];
                }
                if ($str[$i] == '.' && is_numeric($str[$i-1]) && is_numeric($str[$i-1])) {
                    $result.= $str[$i];
                }
                if (($i 1) == strlen($str)) {

                    if ($maxNum == 0 || $maxNum < $result) {
                        $maxNum = $result;
                    }

                    $mumList[] = $result;
                    $result = '';
                }
            } else {
                if ($maxNum == 0 || $maxNum < $result) {
                    $maxNum = $result;
                }
                $mumList[] = $result;
                $result = '';
            }
        }
        $mumList = array_values(array_filter($mumList));
        $a = $mumList[0];
        $c = $mumList[1];
        //只查询备注
        if ($_POST[classid] == "quan" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {

            $sql = "select * from ".$qianzui."account where acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";
        }
        //什么都没填
        if ($_POST[classid] == "quan" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {
            $sql = "select * from ".$qianzui."account where jiid='$_SESSION[uid]' ORDER BY actime ASC";
        }
        //只查询分类
        if ($_POST[classid]<>"quan" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {
            $sqlclassid = "acclassid=".$_POST[classid];
            $sql = "select * from ".$qianzui."account where ".$sqlclassid." and jiid='$_SESSION[uid]' ORDER BY actime ASC";
        }

        //只查询分类收
        if ($_POST[classid] == "zc" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {

            $sql = "select * from ".$qianzui."account where zhifu='2' and jiid='$_SESSION[uid]' ORDER BY actime ASC";
        }
        if ($_POST[classid] == "sr" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu] == "") {

            $sql = "select * from ".$qianzui."account where zhifu='1' and jiid='$_SESSION[uid]' ORDER BY actime ASC";
        }
        //只查询分类支

        //只查询日期
        if ($_POST[classid] == "quan" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {

            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");
            $sql = "select * from ".$qianzui."account where ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }
        if ($_POST[classid] == "quan" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {

            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");
            $sql = "select * from ".$qianzui."account where ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }
        //------------------------------
        //查询分类,日期,备注
        if ($_POST[classid]<>"" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {

            $sqlclassid = "acclassid=".$_POST[classid];
            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

            $sql = "select * from ".$qianzui."account where ".$sqlclassid." and ".$sqltime." and acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }
        //----------------------------------------
        //查询收支,备注
        if ($_POST[classid] == "sr" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {
            $type = "1";


            $sql = "select * from ".$qianzui."account where zhifu='$type' and acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }
        if ($_POST[classid] == "zc" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {
            $type = "2";


            $sql = "select * from ".$qianzui."account where zhifu='$type' and acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }

        //查询收支,日期
        if ($_POST[classid] == "sr" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {
            $type = "1";

            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

            $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }
        if ($_POST[classid] == "zc" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {
            $type = "2";

            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

            $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }
        //查询收支,日期,备注
        if ($_POST[classid] == "sr" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {
            $type = "1";

            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

            $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }
        if ($_POST[classid] == "zc" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {
            $type = "2";

            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

            $sql = "select * from ".$qianzui."account where zhifu='$type' and ".$sqltime." and acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }

        //查询日期,备注
        if ($_POST[classid] == "quan" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu]<>"") {

            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

            $sql = "select * from ".$qianzui."account where ".$sqltime." and acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }


        //--------------------------------------
        //查询分类,备注
        if ($_POST[classid]<>"quan" && $_POST[classid]<>"sr" && $_POST[classid]<>"zc" && $_POST[time1] == "" && $_POST[time2] == "" && $_POST[beizhu]<>"") {

            $sqlclassid = "acclassid=".$_POST[classid];

            $sql = "select * from ".$qianzui."account where ".$sqlclassid." and acmoney>'$a' and acmoney<'$c' and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }

        //查询分类,日期
        if ($_POST[classid]<>"quan" && $_POST[classid]<>"sr" && $_POST[classid]<>"zc" && $_POST[time1]<>"" && $_POST[time2]<>"" && $_POST[beizhu] == "") {

            $sqlclassid = "acclassid=".$_POST[classid];
            $sqltime = " actime >".strtotime($_POST[time1]." 0:0:0")." and actime <".strtotime($_POST[time2]." 23:59:59");

            $sql = "select * from ".$qianzui."account where ".$sqlclassid." and ".$sqltime." and jiid='$_SESSION[uid]' ORDER BY actime ASC";

        }


        echo "
				<table align='left' width='100%' height='20' border='0' align='left' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3' class='table table-striped table-bordered'>
  <tr>
  <td align='left' bgcolor='#EBEBEB'> 查询结果&nbsp;<font id='stat'></font></td>
  </tr>
</table>
<form action='delete.php' method='post'>
 <table id='excel' class='table table-striped' width='100%' border='0' align='left' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3'>
                <tr>
                <th bgcolor='#EBEBEB'>分类</th>
                <th bgcolor='#EBEBEB'>金额</th>
                <th bgcolor='#EBEBEB'>收支</th>
                <th bgcolor='#EBEBEB'>时间</th>
                <th bgcolor='#EBEBEB'>备注</th>
				<th bgcolor='#EBEBEB'><a href='javascript:select()'>全选</a> | <a href='javascript:fanselect()'>反选</a> | <a href='javascript:noselect()'>不选</a> <input type='submit' name='delete' value='删除'/></th>
                </tr>
				";


        $query = mysql_query($sql);
        while ($row = mysql_fetch_array($query)) {
            $sql = "select * from ".$qianzui."account_class where classid= $row[acclassid] and ufid='$_SESSION[uid]'";
            $classquery = mysql_query($sql);
            $classinfo = mysql_fetch_array($classquery);
            echo "<tr>";
            if ($classinfo[classtype] == 1) {
                echo "<td align='left' class='xl26' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>" . $classinfo['classname'] . "</font></td>";
                echo "<td align='left' class='xl29' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>" . $row['acmoney'] . "</font></td>";
                echo "<td align='left' class='xl27' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>收入</font></td>";
                echo "<td align='left' class='xl30' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>".date("Y-m-d",$row[actime])."</font></td>";
                echo "<td align='left' class='xl28' bgcolor='#FFFFFF'><font color='MediumSeaGreen'>". $row[acremark] ."</font></td>";
                $income = $income $row[acmoney];
            } else {
                echo "<td align='left' class='xl26' bgcolor='#FFFFFF'><font color='red'>" . $classinfo['classname'] . "</font></td>";
                echo "<td align='left' class='xl29' bgcolor='#FFFFFF'><font color='red'>" . $row['acmoney'] . "</font></td>";
                echo "<td align='left' class='xl27' bgcolor='#FFFFFF'><font color='red'>支出</font></td>";
                echo "<td align='left' class='xl30' bgcolor='#FFFFFF'><font color='red'>".date("Y-m-d",$row[actime])."</font></td>";
                echo "<td align='left' class='xl28' bgcolor='#FFFFFF'><font color='red'>". $row[acremark] ."</font></td>";
                $spending = $spending $row[acmoney];
            }
            echo "<td align='left' bgcolor='#FFFFFF'><a href=edit.php?id=".$row['acid'].">编辑</a> <a href=delete.php?id=".$row['acid'].">删除</a>
				<input name='del_id[]' type='checkbox' id='del_id[]' value=".$row['acid']." /></td>";
            echo "</tr>";
        }
        echo "</table></form>
				";

    }
}
?>
</div>


<script language="javascript">
document.getElementById("stat").innerHTML = "<?='总共收入<font color=blue> '.$income.'</font> 总共支出 <font color=red>'.$spending.'</font>' ?>"
</script>



<?php
include_once("footer.php");
?>

标签: php 入门 记账

实例下载地址

<赞>php记账本(入门级示例)源码

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警