webかたつむり ウェブデザインを勉強中 ウェブ初心者のおぼえがき

webかたつむり

WEB制作会社のフォトグラファー

php 課題 その4

  • その3でvar_dumpした結果、とれている(サーバーが受け取った)値は「string=文字列」であることがわかる。
  • なので、たとえば「category」のvalueが1だった時、この文字列を変換すれば和食と表示できる。
  • if($category==='1'){$category='和食'}

<?php
$recipe_name=$_POST['recipe_name'];
var_dump($recipe_name);
$category=$_POST['category'];
var_dump($category);
$difficulty=$_POST['difficulty'];
var_dump($difficulty);
$budget=$_POST['budget'];
var_dump($budget);
$howto=$_POST['howto'];
var_dump($howto);

//とれている値を変換する
if($category==='1'){
$category='和食';
}
if($category==='2'){
$category='中華';
}
if($category==='3'){
$category='洋食';
}

if($difficulty==='1'){
$difficulty='簡単';
}
if($difficulty==='2'){
$difficulty='簡単';
}
if($difficulty==='3'){
$difficulty='普通';
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無題ドキュメント</title>
</head>

<body>
<h1>入力内容の確認</h1>
<p>レシピ名:<?php echo $recipe_name; ?></p>
<p>カテゴリー:<?php echo $category; ?></p>
<p>難しさ:<?php echo $difficulty; ?></p>
<p>予算:<?php echo $budget; ?></p>
<p>作り方:<?php echo $howto; ?></p>
</body>
</html> 

f:id:ohta-felica:20160727203346j:plain