问一下有没有代码大佬

V zc V10  (UID: 1996) [复制链接]
帖子链接已复制到剪贴板
帖子已经有人评论啦,不支持删除!

1853 4

求助一下大佬,我之前搭建了一个在线邮局,一直没发现有个小问题

https://www.email.sn.cn/status.php

这是邮局的状态页面,里面有一个已发送和待发送邮件的数据,应该是获取数据库里面的“sent"和"waiting"表,但是问题是,似乎数据对不上,请问有没有大佬帮忙看看。代码如下


<?php
require_once "header.php";
class Row {
  public function __construct($conn) {
    $this->sql = $conn;
  }

  public function getRow($tablename) {
    $this->commed = mysqli_fetch_assoc(mysqli_query($this->sql,"select * from `TABLES` where `TABLE_NAME`='$tablename'"));
    $this->num = $this->commed['TABLE_ROWS'];
    //所有数据
    echo $this->num;
  }
}

class status {
  var $conn;
  var $seconds;
  
  function __construct($conn) {
    $this->sql = $conn;
  }
  
  function getRuntime() {
    $this->Starttime = strtotime("2022-10-26");  //开始时间
    $this->Nowtime = strtotime(date("Y-m-d"));
    $this->diff = $this->Nowtime - $this->Starttime;
    $this->Runtime = abs(round($this->diff / 86400));
    echo $this->Runtime;
  }
}
// 服务是否在运行 | 已发送  | 未发送 | 发送时间段 | 累计运行时间段

$status = new status($conn);
$row = new Row($conns);

?><style>
    .allText{
        text-decoration: underline;
    }
</style>
<div class="mdui-container">
    <div class="mdui-typo">
    <div class="mdui-table-fluid">
      <table class="mdui-table">
        <tbody>
          <tr>
            <td>运行天数</td>
            <td><?php $status->getRuntime();?>天</td>
          </tr>
          <tr>
            <td>已发送</td>
            <td><?php $row->getRow("sent");?>封</td>
          </tr>
          <tr>
            <td>待发送信件</td>
            <td><?php $row->getRow("waiting");?>封</td>
          </tr>
        </tbody>
      </table>
    </div></div></div>
    <?php require_once "footer.php"; ?>
email.ooo
已有评论 ( 4 )
  • 头像
    V 小树 (UID: 4412)
    (🔞 这个家伙太懒了,留下了很多东西。)
    1楼

    楼下大佬看看

  • 头像
    站长 (UID: 653)
    (67t.cn)
    2楼

    问问神奇多多gtp

  • 头像
    V Dream 5.0 (UID: 1051)
    3楼

    4o给的答案表情

    <?php

    require_once  "header.php";

     

    class  Row  {

            public  function  __construct($conn)  {

                    $this->sql  =  $conn;

            }

     

            public  function  getRow($tablename)  {

                    //  修改查询语句,获取表中的行数

                    $query  =  "SELECT  COUNT(*)  as  count  FROM  `$tablename`";

                    $result  =  mysqli_query($this->sql,  $query);

     

                    if  (!$result)  {

                            echo  "查询错误:  "  .  mysqli_error($this->sql);

                            return;

                    }

     

                    $row  =  mysqli_fetch_assoc($result);

                    $this->num  =  $row['count'];  //  获取行数

                    echo  $this->num;

            }

    }

     

    class  Status  {

            var  $conn;

     

            function  __construct($conn)  {

                    $this->sql  =  $conn;

            }

     

            function  getRuntime()  {

                    $this->Starttime  =  strtotime("2022-10-26");  //  开始时间

                    $this->Nowtime  =  strtotime(date("Y-m-d"));

                    $this->diff  =  $this->Nowtime  -  $this->Starttime;

                    $this->Runtime  =  abs(round($this->diff  /  86400));

                    echo  $this->Runtime;

            }

    }

     

    //  确保使用同一个连接变量

    $status  =  new  Status($conn);

    $row  =  new  Row($conn);

    ?>

     

    <style>

            .allText  {

                    text-decoration:  underline;

            }

    </style>

     

    <div  class="mdui-container">

            <div  class="mdui-typo">

                    <div  class="mdui-table-fluid">

                            <table  class="mdui-table">

                                    <tbody>

                                            <tr>

                                                    <td>运行天数</td>

                                                    <td><?php  $status->getRuntime();  ?>天</td>

                                            </tr>

                                            <tr>

                                                    <td>已发送</td>

                                                    <td><?php  $row->getRow("sent");  ?>封</td>

                                            </tr>

                                            <tr>

                                                    <td>待发送信件</td>

                                                    <td><?php  $row->getRow("waiting");  ?>封</td>

                                            </tr>

                                    </tbody>

                            </table>

                    </div>

            </div>

    </div>

     

    <?php

    require_once  "footer.php";

    ?>

  • 头像
    V 袁某人 (UID: 547)
    (博客 JB18.CM | 主页 WO.JB18.CM)
    4楼

    上下文和数据都看不到,看个🐦

域名市场
   域名载入中...
创建新帖
自助推广购买广告位
确认删除
确定要删除这篇帖子吗?删除后将无法恢复。
删除成功
帖子已成功删除,页面将自动刷新。
删除失败
删除帖子时发生错误,请稍后再试。