
#HTMLのみで記載しているヘッダーと追加窓欄は、widthが効いているのですが配列から$rowで取り出したPHPのecho内に記載したHTMLタグのwidthだけが効かないと云った状況です。
同じように設定しても、効かないのは何故なのでしょうか?tabe内のinputをclass addを付けて画面サイズが変わっても幅いっぱいに表示にするようにしています。
1行目と2行目がHTMLとCSSのみで形成、一番下だけPHPのecho内でHTMLタグを出力しています。
以下ソースコードです。CSS HTML(ヘッダー部分) PHP部分です。
CSS
1 2table.head { 3 width: 100%; 4 text-align: center; 5 border:solid 1px #000; 6} 7 8.header{ 9 width: 100%; 10} 11 12table.head th { 13 background-color:silver; 14 text-align: center; 15 border:solid 1px #000; 16} 17 18table.main { 19 width: 100%; 20} 21 22table.add{ 23 width: 100%; 24 color:red; 25} 26 27input.add { 28 width: 100%; 29}
HTML
1 <table class="main"> 2 <tr> 3 <form action="edit.php" method="post" onsubmit="return false;"> 4 <input type="hidden" name="command" value="insert"> 5 <!--データベース接続時条件保存用--> 6 <input type="hidden" name ="locationset" value="<?php echo $locationset ?>"> 7 <input type="hidden" name ="date1" value="<?php echo $date1 ?>"> 8 <input type="hidden" name ="date2" value="<?php echo $date2 ?>"> 9 <!--ここまで--> 10 <td style="width:8%"><input type ="text" name="workday" value="<?php echo date('Y-m-d', strtotime('+1 day'));?>" class="add"></td> 11 <td style="width:12%"><input type ="text" name="workgroup" class="add"></td> 12 <td style="width:18%"><input type ="text" name="personal" class="add"></td> 13 <td style="width:18%"><input type ="text" name="product" class="add"></td> 14 <td style="width:5%"><input type ="text" name="unit" class="add"></td> 15 <td style="width:5%"><input type ="text" name="createcnt" class="add"></td> 16 <td style="width:8%"><input type ="text" name="bestbydata" class="add"></td> 17 <td style="width:18%"><input type ="text" name="remarks" class="add"></td> 18 <td colspan="2" style="width:8%"> 19 <input type="button" class ="add" value="追加" onclick="window.location.reload(true),submit();"></td> 20</form> 21</tr> 22</table>
PHP
1<table class="main"> 2<?php 3try{ 4//if (isset($_REQUEST['select'])) { 5foreach ($pdo ->query($sql)as $row){ // where workdayで抽出条件を設定する 6 echo '<tr>'; 7 echo '<form action="edit.php" method="post">'; 8 echo '<input type="hidden" name="command" value="update">'; 9 echo '<input type="hidden" name="id" value="',$row['id'],'">'; 10 echo '<input type="hidden" name="locationset" value="', $locationset , '">'; 11 echo '<input type="hidden" name ="date1" value="', $date1 ,'">'; 12 echo '<input type="hidden" name ="date2" value="', $date2 ,'">'; 13 //echo '<td>',$row['id'],'</td>'; ID非表示 14 echo '<td style="width:8%"><input type ="text" name="workday" class="add" value="',$row['workday'],'"></td>';//dateを使うなら、SQLの前でreplace 15 echo '<td style="width:12%"><input type ="text" name="workgroup" class="add" value="',$row['workgroup'],'"></td>'; 16 echo '<td style="width:18%"><input type ="text" name="personal" class="add" value="',$row['personal'],'"></td>'; 17 echo '<td style="width:18%"><input type ="text" name="product" class="add" value="',$row['product'],'"></td>'; 18 echo '<td style="width:5%"><input type ="text" name="createcnt" class="add2" value="',$row['createcnt'],'"></td>'; 19 echo '<td style="width:5%"><input type ="text" name="unit" class="add2" value="',$row['unit'],'"></td>'; 20 echo '<td style="width:8%"><input type ="text" name="bestbydata" class="add" value="',$row['bestbydata'],'"></td>'; 21 echo '<td style="width:18%"><input type ="text" name="remarks" class="add" value="',$row['remarks'],'"></td>'; 22 echo '<td style="width:4%"><input type="button" class="add" value="更新" class="add" onclick="window.location.reload(true),submit()"></td>'; 23 echo '</form>'; 24 echo '<form action="edit.php" method="post">'; 25 echo '<input type="hidden" name="command" value="delete">'; 26 echo '<input type="hidden" name="id" value="', $row['id'], '">'; 27 echo '<input type="hidden" name="locationset" value="', $locationset , '">'; 28 echo '<input type="hidden" name ="date1" value="', $date1 ,'">'; 29 echo '<input type="hidden" name ="date2" value="', $date2 ,'">'; 30 echo '<td style="width:4%"><input type="button" class="add" value="削除" onclick="window.location.reload(true),submit();"></td>'; 31 echo '</form>'; 32 echo '</tr>'; 33} 34// } 35}catch(PDOException $e) { 36 $error = $e->getMessage(); 37 echo $error; 38}?> 39</table>
echoで出力したHTMLソース
HTML
1<td style="width:8%"> 2 <input type ="text" name="workday" class="add" value="2020-01-11"> 3</td> 4<td style="width:12%"> 5 <input type ="text" name="workgroup" class="add" value="横ピロB"> 6</td> 7<td style="width:18%"> 8 <input type ="text" name="personal" class="add" value="村田・阿部・二岡・仁志・高橋(由)"></td> 9<td style="width:18%"> 10 <input type ="text" name="product" class="add" value="アスクル小粒キャンディ"> 11</td> 12<td style="width:5%"> 13 <input type ="text" name="createcnt" class="add2" value="400"> 14</td> 15<td style="width:5%"> 16 <input type ="text" name="unit" class="add2" value="kg"> 17</td> 18<td style="width:8%"> 19 <input type ="text" name="bestbydata" class="add" value="-"> 20</td> 21<td style="width:18%"> 22 <input type ="text" name="remarks" class="add" value="-"> 23</td> 24<td style="width:4%"> 25 <input type="button" class="add" value="更新" class="add" onclick="window.location.reload(true),submit()"> 26</td> 27</form> 28<form action="edit.php" method="post"> 29 <input type="hidden" name="command" value="delete"> 30<td style="width:4%"> 31 <input type="button" class="add" value="削除" onclick="window.location.reload(true),submit();"> 32</td> 33</form> 34</tr> 35~ 36次の行へ~ 37コード
回答2件
あなたの回答
tips
プレビュー