【问题标题】:Loop and Insert monthly schedule by PHP通过 PHP 循环和插入每月计划
【发布时间】:2015-02-21 03:24:15
【问题描述】:

我现在正在制定贷款月度计划,但在使用 php 和 mysql 生成月度计划时遇到了问题。 我的问题是: 示例:贷款日期 = 2/12/2015,期限 = 5 个月 我不知道如何像这样插入数据库:

<table border='1' cellspacing='0' cellpading='0'>
  <tr>
    <th>Month</th>
     <th>Date</th>
  </tr>
  <tr>
    <th>1st month</th>
     <th>2/12/2015</th>
  </tr>
  <tr>
    <th>2nd month</th>
     <th>3/12/2015</th>
  </tr>
  <tr>
    <th>3rd month</th>
     <th>4/12/2015</th>
  </tr>
  <tr>
    <th>4th month</th>
     <th>5/12/2015</th>
  </tr>
  <tr>
    <th>5th month</th>
     <th>6/12/2015</th>
  </tr>
  <tr>
    <th>6th month</th>
     <th>7/12/2015</th>
  </tr>
<table>

【问题讨论】:

  • 那么您想在数据库中插入所有 6 个日期值吗?为什么不直接插入第一个月和持续时间/上个月,并在需要时生成其余部分?
  • 这是 HTML 片段?你打算在数据库中插入 HTML 吗?你的表结构是什么?连接数据库和插入查询的代码在哪里?

标签: javascript php mysql codeigniter


【解决方案1】:

在此查询中,从您的时间戳值中添加下个月,您可以根据您的持续时间进行调整,试试这个

INSERT INTO `tbl_book`(`book_date`) VALUES (now( ) + INTERVAL 1 MONTH)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-11
    • 2016-10-17
    • 2011-05-04
    • 1970-01-01
    • 2016-08-27
    相关资源
    最近更新 更多