Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
10php
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu Kimiduka
10php
Commits
18afeb0e
Commit
18afeb0e
authored
Jul 20, 2016
by
君塚 悠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
プログラム作成(schedule.php,MySmarty.class.php,schedule.tpl:Smartyを用いたスケジュール帳
parent
5180c9a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
0 deletions
+77
-0
MySmarty.class.php
php/php10/day10-3/MySmarty.class.php
+32
-0
schedule.php
php/php10/day10-3/schedule.php
+20
-0
schedule.tpl
php/php10/day10-3/schedule.tpl
+25
-0
No files found.
php/php10/day10-3/MySmarty.class.php
0 → 100644
View file @
18afeb0e
<?php
// MySmartyのクラスファイル
require_once
(
"DB.php"
);
require_once
(
"Smarty/libs/Smarty.class.php"
);
// 諸設定を行なう
class
MySmarty
extends
Smarty
{
private
$_db
;
public
function
__construct
()
{
$this
->
Smarty
();
$this
->
template_dir
=
"./templates"
;
$this
->
compile_dir
=
"./templates_c"
;
$this
->
cache_dir
=
"./cache"
;
$this
->
caching
=
FALSE
;
$this
->
security
=
TRUE
;
$this
->
_db
=
DB
::
connect
(
"sqlite://localhost/schedule.sqlite"
);
}
// 終了時にDBと接続を切る
public
function
__destruct
()
{
$this
->
_db
->
desconnect
();
}
// DBのデータを取得する
public
function
get_db
()
{
return
$this
->
_db
;
}
}
\ No newline at end of file
php/php10/day10-3/schedule.php
0 → 100644
View file @
18afeb0e
<?php
// DBのsheduleテーブルの内容を配列にコピーし、
// Smartyのテンプレートにその配列を割り当て、出力する。
require_once
(
"MySmarty.class.php"
);
$o_smarty
=
new
MySmarty
();
$db
=
$o_smarty
=
new
MySmarty
();
$stt
=
$db
->
prepare
(
"SELECT * FROM schedule ORDER BY s_date, s_time"
);
$rs
=
$db
->
excute
(
$stt
);
while
(
$row
=
$rs
->
fetchRow
(
DB_FETCHMODE_ASSOC
))
{
$data
[]
=
array
(
'sid'
=>
$row
[
'sid'
],
'title'
=>
$row
[
'title'
],
's_date'
=>
$row
[
's_date'
],
's_time'
=>
$row
[
's_time'
],
'memo'
=>
$row
[
'memo'
]);
}
$db
->
disconnect
();
// Smartyのテンプレートに値を割り当てる
$o_smarty
->
assign
(
"sches"
,
$data
);
// テンプレートを出力する
$o_smarty
->
display
(
"schedule.tpl"
);
?>
php/php10/day10-3/schedule.tpl
0 → 100644
View file @
18afeb0e
<html>
<head>
<title>
簡易スケジュール帳
</title>
</head>
<body>
<h1
style =
"background:#cccccc"
>
簡易スケジュール帳
</h1>
<table
border =
"1"
>
<tr>
<th>
日付
</th><th>
時刻
</th><th>
予定名
</th><th>
備考
</th><th>
削除
</th>
</tr>
//配列の内容を出力
{
foreach
from
=
$sches
item
=
"sche"
}
<tr>
<td>
{
$che.s_date
}
</td>
<td>
{
$che.s_time
}
</td>
<td>
{
$che.title
}
</td>
<td>
{
$che.memo
}
</td>
<td>
<input
type =
"button"
value =
"削除"
onclick=
"location.href = 'schedule_dalete.php?sid =<?php print($row['sid']); ?>'"
/></td>
</tr>
{/
foreach
}
</table>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment