• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

台历价格表

php 搞代码 3年前 (2022-01-24) 23次浏览 已收录 0个评论

日历价格表?
问题:价格人数信息不能对应数组里面有的日期才显示(比如数组里面有2013-10-12和2013-10-21才有价格和人数,但程序会依次从开始日期显示,而不是在生成的日历里面对应的日期里才显示),有高手请指点一下,越改逻辑越混乱了。
现在效果如图:
代码如下:
<?php

class productDate{
var $product_id = ”;
var $date = ”;
var $original_date = ”;
var $nextDate = ”;
var $prices = ”;

var $count = 42;

var $nowWeek;
var $nowMonth;
var $nextMonth;
var $startDate;
var $lastDate;

function create($prod

本&文来源gaodai^.ma#com搞#代!码网

搞gaodaima代码uct_id, $date, $prices){
$this->product_id = $product_id;
$this->original_date = $this->date = strtotime($date);
$this->prices = $prices;
$this->_init();
$datesTmp = array_keys($this->prices);
$this->lastDate = array_pop($datesTmp);
}
/**
* 下一个月
*
*/
function createNext(){
$this->nextDate = $date; //下一月, 待处理
$this->create($this->nextDate);
}

function getNextMonth($tmp_date, $step = 1){
//切割出年份
$tmp_year= date(‘Y’, $tmp_date);
//切割出月份
$tmp_mon =date(‘m’, $tmp_date);
$tmp_nextmonth=mktime(0,0,0,$tmp_mon + $step,1,$tmp_year);
//得到当前月的下2个月 ,最晚的日期的下一个月的开始
return $tmp_nextmonth;
}

function getPreMonth($tmp_date, $step = 1){
//切割出年份
$tmp_year= date(‘Y’, $tmp_date);
//切割出月份
$tmp_mon =date(‘m’, $tmp_date);
$tmp_premonth=mktime(0,0,0,$tmp_mon – $step,1,$tmp_year);
//得到当前月的上一个月
return $tmp_premonth;
}
/**
* 初始化参数
*
*/
function _init(){
$this->nowWeek = date(‘w’, $this->date);
$this->nowMonth = date(‘m’, $this->date);
$this->nextMonth = date(‘m’, $this->date + 86400 * $this->count);
$this->startDate = $this->date – 86400 * $this->nowWeek;//获取开始日期
}
/**
* 获取html
*
*/
function getHtml(){
$box = $this->getBox();
while($this->getNextMonth($this->date, 2) lastDate){
$this->date = $this->getNextMonth($this->date);
$this->_init();
$box .= $this->getBox();
}

return <<<EOF

product_id}”>
{$box}

EOF;
}
/**
* 获取日历块
*
*/
function getBox(){
$result = ‘

    ‘;
    $startDate = $this->startDate;

    for($i = 0; $i count; $i++){


    搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
    转载请注明原文链接:台历价格表

    喜欢 (0)
    [搞代码]
    分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址