-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
家計簿アクション一連のinput, record, search, output の基本成功確認した。
- Loading branch information
0 parents
commit 450b976
Showing
5 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
function getDb(){ | ||
$dsn='mysql:dbname=test; host=localhost; charset=utf8'; | ||
$usr= 'admin'; | ||
$passwd='admin'; | ||
|
||
try { | ||
$db = new PDO($dsn, $usr, $passwd); | ||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
$db ->exec('SET NAMES utf8'); | ||
} catch (PDOException $e) { | ||
die("接続エラー:{$e->getMessage()}"); | ||
} | ||
return $db; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
$action_person = $_POST['action_person']; | ||
$pdo = new PDO('mysql:host=localhost;dbname=test', admin, admin); | ||
$stt = $pdo-> prepare('insert into group_kakeibo_action values(null, :action_date, :action_person, :himoku, | ||
:memo, :income, :outcome)'); | ||
$stt->bindValue(':action_date', $_POST['action_date']); | ||
$stt->bindValue(':action_person', $_POST['action_person']); | ||
$stt->bindValue(':himoku', $_POST['himoku']); | ||
$stt->bindValue(':memo', $_POST['memo']); | ||
$stt->bindValue(':income', $_POST['income']); | ||
$stt->bindValue(':outcome', $_POST['outcome']); | ||
$stt->execute(); | ||
|
||
|
||
|
||
echo $action_person,'の家計簿を、登録しました'; | ||
echo '<a href="search_group_kakeibo_action.php">家計簿一覧表示</a>'; | ||
|
||
/* ここどうかな bindValue のやつを入れようかな、、、 | ||
* | ||
* | ||
*/ | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>入力用画面(家計簿)</title> | ||
</head> | ||
<body> | ||
|
||
<form action="finished_group_kakeibo_action.php" method="post"> | ||
|
||
<h2>日付</h2> | ||
<input type="date" name="action_date" /> | ||
<h2>人物</h2> | ||
<input type="text" name="action_person" /> | ||
<h2>費目</h2> | ||
<input type ="text" name ="himoku"> | ||
<h2>メモ</h2> | ||
<input type="text" name="memo"> | ||
<h2>入金額</h2> | ||
<input type="number" name="income" > | ||
<h2>出金額</h2> | ||
<input type="number" name="outcome" > | ||
|
||
<br> | ||
<input type="submit" value="登録"> | ||
|
||
</form> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
require_once 'DbManager.php'; | ||
?> | ||
|
||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>検索結果の表示</title> | ||
</head> | ||
<body> | ||
<h1>検索結果</h1> | ||
<h2>以下の検索結果が見つかりました。</h2> | ||
|
||
<?php | ||
$pdo = getDb(); | ||
try { | ||
$stt = $pdo-> prepare('select * from group_kakeibo_action where action_date= :action_date'); | ||
|
||
$stt->bindValue(':action_date', $_POST['action_date']); | ||
$stt-> execute(); | ||
while($row = $stt -> fetch(PDO:: FETCH_ASSOC)){ | ||
print('日付:'.$row['action_date'].'<br />'); | ||
print('人物:'.$row['action_person'].'<br />'); | ||
print('費目:'.$row['himoku'].'<br />'); | ||
print('メモ:'.$row['memo'].'<br />'); | ||
print('入金額:'.$row['income'].'<br />'); | ||
print('出金額:'.$row['outcome'].'<br />'); | ||
|
||
|
||
} | ||
|
||
} catch (Exception $e) { | ||
print('エラーメッセージ'.$e->getMessage()); | ||
} | ||
?> | ||
<a href="search_group_kakeibo.php" >家計簿検索ページにもどる</a> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>家計簿の内容検索</title> | ||
</head> | ||
<body> | ||
<h1>検索してください</h1> | ||
<h2>日付で検索</h2> | ||
<form action="output_group_kakeibo_action.php" method="post"> | ||
<input type="date" name="action_date"> | ||
<input type="submit" value="検索"> | ||
</form> | ||
<h2>人物で検索</h2> | ||
<h2>費目で検索</h2> | ||
<h2>メモで検索</h2> | ||
<h2>入金額で検索</h2> | ||
<h2>出金額で検索</h2> | ||
</body> | ||
</html> |