Skip to content

Commit

Permalink
家計簿アクション一連のinput, record, search, output の基本成功確認した。
Browse files Browse the repository at this point in the history
  • Loading branch information
match8969 committed Oct 25, 2017
0 parents commit 450b976
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
17 changes: 17 additions & 0 deletions DbManager.php
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;
}

?>
25 changes: 25 additions & 0 deletions finished_group_kakeibo_action.php
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 のやつを入れようかな、、、
*
*
*/


?>
29 changes: 29 additions & 0 deletions input_group_kakeibo_action.php
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>
39 changes: 39 additions & 0 deletions output_group_kakeibo_action.php
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>
19 changes: 19 additions & 0 deletions search_group_kakeibo_action.php
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>

0 comments on commit 450b976

Please sign in to comment.