导航:首页 > 编程语言 > php制作日历

php制作日历

发布时间:2022-09-05 02:26:57

① 求助:关于php制作日历的问题

$php_self?year=$y_lnk1&month=$month中的$php_self是链接地址,这里给出的是一个变量来代替冗长的字符串,比如说www.phpfans.net,问号后面的year、month传的参数,并分别给他们赋值为$y-lnk、$month。
添加该链接出错是语法错误!将双引号去掉即可。

② PHP和数据库做日历 高手给点帮助呗 简单点就行 求代码

<?php
if(isset($_GET['add_flag']) ){
require_once './Setting.php';
try {
$dbm = new DBManager($dsn, $user, $passwd);

$db = $dbm->getDB();
$stt = $db->prepare('INSERT INTO diary(date1,title,content,weather,feeling) VALUES(:date1,:title,:content,:weather,:feeling)');

$stt->bindValue(':date1', $_GET['date1']);
$stt->bindValue(':title', $_GET['title']);
$stt->bindValue(':content', $_GET['content']);
$stt->bindValue(':weather', $_GET['weather']);
$stt->bindValue(':mood', $_GET['mood']);
$stt->execute();
} catch(PDOException $e){
die("エラー: {$e}");
}
$db = null;
$dbm = null;
header('Location: ./main.php');
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ユーザ管理システム - ユーザの追加</title>
<script src="./sd.js" type="text/javascript"></script>
</head> <body>
<div id="header">
<h1>ユーザ管理システム</h1>
<h2>ユーザの追加</h2>
<?php

?>
</div>
<form action="./add_user.php" method="get">
<input type="hidden" size="5" name="id"><br>
<table>
<tr>
<td>date:</td>
<td><input type="TextBox" size="20" name="date1" ID="TextBox1" onfocus="calendar()" runat="server"></td>
</tr>
<tr>
<td>title:</td>
<td><input type="text" size="20" name="title"></td>
</tr>
<tr>
<td>content:</td>
<td><textarea name="content" cols = "45" rows = "5"></textarea></td>
</tr>
<tr>
<td>weather:</td>
<td><input type="radio" name="weather" value="阴" id="weather1" checked>
<label for="weather1" style="background-image: rainy.jpg)">rainy</label>
<input type="radio" name="weather" value="晴" id="weather2">
<label for="weather2" style="background-image: sunny.jpg)">sunny</label></td>
</tr>
<tr>
<td>mood:</td>
<td><input type="radio" name="feeling" value="happy" id="mood1" checked style="background-image: happy.jpg)">
<label for="mood1">happy</label>
<input type="radio" name="feeling" value="伤心" id="mood2" style="background-image: sad.jpg)" >
<label for="mood2">sad</label></td>
</tr>

<br>
</table>
<input type="hidden" name="add_flag" value="true">
<input type="submit" value="Add">
</form>
<p><a href="./main.php">トップ画面へ戻る</a></p>
</body>
</html>

③ HTML5+PHP要怎么制作日历

JS有个dataPicker控件,如果是自己来做需要写循环判断算法

④ PHP如何生成一个指定年份一整年的日历

从你的描述看来,只需要知道指定年份的每个月的天数和每天对应的周次即可。
PHP中 Calendar 函数可以实现第一步:
int cal_days_in_month ( int $calendar , int $month , int $year )
剩下的就是写循环遍历所有月,按月生成日历了。

⑤ 制作一个php代码要求是实现日历功能

PHP写的日历代码,网上有很多,有简单也有复杂的,具体的代码要看你的需要来确定。

考虑到做课题的话,个人推荐使用《PHP经典实例》一书中第3章最后一节,有个完整的 日历 的代码,建议你可以拿来参考,并且建议将该书第3章的内容都看一下。

《PHP经典实例》网上有电子版。

⑥ php日历插件的制作方法,求思路

<?phpheader("content-type:text/html;charset=utf-8");?>
<?php?>
<tableclass="tabletable-stripedtable-hover">
<?php
//注:32位机器或者32位PHP版本可能只能计算到2038年之前的月份
//若没有GET方法传入参数,则使用服务器本地当前日期;否则使用传入的参数,方便跳转月份
$year=date("Y");
$month=date("n");
$alert="<divclass='alertalert-warning'>输入的日期格式有误!</div>";
$alertYear="<divclass='alertalert-warning'>无法计算1901年以前的日历!</div>";
if($_REQUEST){
$year=$_REQUEST["year"];
$month=$_REQUEST["month"];
}
if(!in_array($month,array("1","2","3","4","5","6","7","8","9","10","11","12"))){echo$alert;exit;}
if($year<1901){echo$alertYear;exit;}
?>
<caption><h4><?phpecho$year;?>&nbsp;年&nbsp;<?phpecho$month;?>&nbsp;月</h4></caption>
<?php
//计算当前日期,当月天数,获得星期数据,将默认星期天数字0改为7,方便处理循环
$today=date("j");
$days=date("t",strtotime("$year-$month-01"));
$week=date("w",strtotime("$year-$month-01"));
if($week==0){$week=7;}
?>
<tr>
<th>一</th>
<th>二</th>
<th>三</th>
<th>四</th>
<th>五</th>
<th>六</th>
<th>日</th>
</tr>
<tr>
<?php
//插入空白无日期区域,循环次数为当前月第一天的星期数-1
for($space=1;$space<$week;$space++){
echo"<td>-</td>";
}
//循环插入数据,当到达周日时换行输出;标记当前日期为红色
for($day=1;$day<=$days;$day++){
if(($day+$week-1)%7===0){
if($day==$today&&$year==date("Y")&&$month==date("n")){
echo"<tdstyle='background-color:pink;'>$day</td>";
echo"</tr>";
echo"<tr>";
}
echo"<td>$day</td>";
echo"</tr>";
echo"<tr>";
}else{
if($day==$today&&$year==date("Y")&&$month==date("n")){
echo"<tdstyle='background-color:pink;'>$day</td>";
}else{
echo"<td>$day</td>";
}
}
}
//尾部补足
$spacing=36-$days-$week<0?43-$days-$week:36-$days-$week;
for($footer=1;$footer<=$spacing;$footer++){
echo"<td>-</td>";
}
?>
</tr>
</table>

我以前写的,你随意看看~~

⑦ php中将一年12个月的日历全部输出。如何做

<?php
//SKY8G提供
function cal_days_in_year($year){
$days=0;
for($month=1;$month<=12;$month++){
$days = $days + cal_days_in_month(CAL_GREGORIAN,$month,$year);
}
return $days;
}
//闰年
echo "这是闰年一年有:".cal_days_in_year(2000)."天";
echo "\n";
//平年
echo "这是平年一年有:".cal_days_in_year(1999)."天";
echo "\n";
//2019年
echo "今年2019年有:".cal_days_in_year(date('Y',time()))."天";
echo "\n";
//接下来我们是用php的内置函数cal_days_in_month()
$d=cal_days_in_month(CAL_GREGORIAN,2,2010);
echo "2010 年平年 2 月有 $d 天。\n";
$d=cal_days_in_month(CAL_GREGORIAN,2,2000);
echo "2000 年闰年 2 月有 $d 天。";
echo "\n";
$d=cal_days_in_month(CAL_GREGORIAN,4,2010);
echo "2010 年平年 4 月有 $d 天。\n";
$d=cal_days_in_month(CAL_GREGORIAN,4,2000);
echo "2000 年闰年 4 月有 $d 天。";
echo "\n";
$d=cal_days_in_month(CAL_GREGORIAN,8,2010);
echo "2010 年平年 8 月有 $d 天。\n";
$d=cal_days_in_month(CAL_GREGORIAN,8,2000);
echo "2000 年闰年 8 月有 $d 天。";
//详情如果想了解详情去sky8g网观看,希望对你有帮助!

⑧ 如何用PHP制作日历

calendar.class.php
代码如下:
<?php
classCalendar{
private$year;//当前的年
private$month;//当前的月
private$start_weekday;//当月的第一天对应的是周几
private$days;//当前月一共多少天

function__construct(){
$this->year=isset($_GET["year"])?$_GET["year"]:date("Y");
$this->month=isset($_GET["month"])?$_GET["month"]:date("m");

$this->start_weekday=date("w",mktime(0,0,0,$this->month,1,$this->year));
$this->days=date("t",mktime(0,0,0,$this->month,1,$this->year));
}

functionout(){
echo'<tablealign="center">';
$this->chageDate("test.php");
$this->weeksList();
$this->daysList();
echo'</table>';
}

privatefunctionweeksList(){
$week=array('日','一','二','三','四','五','六');

echo'<tr>';
for($i=0;$i<count($week);$i++)
echo'<thclass="fontb">'.$week[$i].'</th>';

echo'</tr>';
}

privatefunctiondaysList(){
echo'<tr>';
//输出空格(当前一月第一天前面要空出来)
for($j=0;$j<$this->start_weekday;$j++)
echo'<td></td>';


for($k=1;$k<=$this->days;$k++){
$j++;
if($k==date('d'))
echo'<tdclass="fontb">'.$k.'</td>';
else
echo'<td>'.$k.'</td>';

if($j%7==0)
echo'</tr><tr>';

}

//后面几个空格
while($j%7!==0){
echo'<td></td>';
$j++;
}

echo'</tr>';
}

privatefunctionprevYear($year,$month){
$year=$year-1;

if($year<1970)
$year=1970;

return"year={$year}&month={$month}";
}


privatefunctionprevMonth($year,$month){
if($month==1){
$year=$year-1;

if($year<1970)
$year=1970;

$month=12;
}else{
$month--;
}

return"year={$year}&month={$month}";
}


privatefunctionnextYear($year,$month){
$year=$year+1;

if($year>2038)
$year=2038;

return"year={$year}&month={$month}";
}


privatefunctionnextMonth($year,$month){
if($month==12){
$year++;

if($year>2100)
$year=2100;

$month=1;
}else{
$month++;
}


return"year={$year}&month={$month}";
}

privatefunctionchageDate($url=""){
echo'<tr>';
echo'<td><ahref="?'.$this->prevYear($this->year,$this->month).'">'.'<<'.'</a></td>';
echo'<td><ahref="?'.$this->prevMonth($this->year,$this->month).'">'.'<'.'</a></td>';
echo'<tdcolspan="3">';
echo'<form>';
echo'<selectname="year"onchange="window.location=''.$url.'?year='+this.options[selectedIndex].value+'&month='.$this->month.''">';
for($sy=1970;$sy<=2100;$sy++){
$selected=($sy==$this->year)?"selected":"";
echo'<option'.$selected.'value="'.$sy.'">'.$sy.'</option>';
}
echo'</select>';
echo'<selectname="month"onchange="window.location=''.$url.'?year='.$this->year.'&month='+this.options[selectedIndex].value">';
for($sm=1;$sm<=12;$sm++){
$selected1=($sm==$this->month)?"selected":"";
echo'<option'.$selected1.'value="'.$sm.'">'.$sm.'</option>';
}
echo'</select>';
echo'</form>';
echo'</td>';


echo'<td><ahref="?'.$this->nextYear($this->year,$this->month).'">'.'>>'.'</a></td>';
echo'<td><ahref="?'.$this->nextMonth($this->year,$this->month).'">'.'>'.'</a></td>';
echo'</tr>';
}

}
?>test.php

代码如下:
<style>
table{
border:1pxsolid#050;
}

.fontb{
color:white;
background:blue;
}


th{
width:30px;
}

td,th{
height:30px;
text-align:center;

}
form{
margin:0px;
padding:0px;
}
</style>
<?php
include"calendar.class.php";

$calendar=newCalendar;

$calendar->out();
?>

阅读全文

与php制作日历相关的资料

热点内容
unix网络编程卷4 浏览:805
找靓机app下单什么时候发货 浏览:411
android一个应用两个进程 浏览:801
linux硬盘复制 浏览:806
php图片服务器搭建 浏览:798
下载压缩文件怎么打开 浏览:192
新建文件夹叫什么名字 浏览:565
windows20的开机命令 浏览:332
微信一般在电脑的那个文件夹 浏览:509
go在win7下编译特别慢 浏览:256
光遇ios耳机安卓为什么没有 浏览:904
小米手机桌面文件夹经常自动散开 浏览:607
小米电话手表用什么app进行设置 浏览:265
虚拟打印机pdf下载 浏览:671
jdk编译运行方法 浏览:459
android执行shell命令 浏览:349
程序员头像女 浏览:57
有什么可以变头发颜色的app 浏览:935
玩具解压屋游戏下载 浏览:849
我的世界拔刀剑服务器地址id 浏览:891