導航:首頁 > 編程語言 > 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製作日歷相關的資料

熱點內容
獲取命令方 瀏覽:976
怎樣製作文件夾和圖片 瀏覽:58
調研編譯寫信息 瀏覽:859
python馮諾依曼 瀏覽:417
同時安裝多個app有什麼影響 瀏覽:252
奧術殺戮命令宏 瀏覽:182
用sdes加密明文字母e 瀏覽:359
單片機原理及應用試題 瀏覽:423
易語言開啟指定文件夾 瀏覽:40
馬思純參加密室大逃脫 瀏覽:322
文件夾冬季澆築溫度 瀏覽:712
京東有返點的aPp叫什麼 瀏覽:603
如何查看u點家庭伺服器是幾兆 瀏覽:262
python應用介面怎麼接 瀏覽:67
腐蝕怎麼進不去伺服器啊 瀏覽:359
linuxcpiogz 瀏覽:631
安卓中的布局是什麼文件 瀏覽:397
dex反編譯部分代碼無法查看 瀏覽:464
linuxandroid編譯 瀏覽:603
程序員電視劇20集 瀏覽:910