php - 我的错误消息在其左侧的错误消息下方格式化
问题描述
我的错误消息显示在我的其他错误消息下方。我正在努力做到这一点,以便在出现错误时它们彼此相邻显示。这是错误消息之前的样子:错误之前 这是我收到错误时的样子:错误消息。为了更清楚,我希望错误消息位于“选择样式:”和“选择尺寸:”上方
我尝试应用 css 以使用边距正确格式化它,我尝试添加空格。两者都没有工作。
<?php
if(($_POST['style'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
echo "<strong>Please select a clothing style!</strong><br />";
}
?>
<div class="style" style="width 100px; float:left; height 100px; margin:0px;">
<!-- this code asks the suer what clothing style they like. They have a lot of options. The code is like the gender code -->
Select a style: <br />
<label> <input type="radio" name="style" value="Casual"
<?php
if ($_POST['style'] == 'Casual') {
echo "checked";
}
?>
/>Casual</label><br />
<label> <input type="radio" name="style" value="Athletic"
<?php
if ($_POST['style'] == 'Athletic') {
echo "checked";
}
?>
/>Athletic</label><br />
<label> <input type="radio" name="style" value="Vintage"
<?php
if ($_POST['style'] == 'Vintage') {
echo "checked";
}
?>
/>Vintage</label><br />
<label> <input type="radio" name="style" value="Formal"
<?php
if ($_POST['style'] == 'Formal') {
echo "checked";
}
?>
/>Formal</label><br />
<label> <input type="radio" name="style" value="Streetwear"
<?php
if ($_POST['style'] == 'Streetwear') {
echo "checked";
}
?>
/>Streetwear</label><br />
<label> <input type="radio" name="style" value="Rocker"
<?php
if ($_POST['style'] == 'Rocker') {
echo "checked";
}
?>
/>Rocker</label>
</div>
<?php
if(($_POST['size'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
echo "<strong>Please select a clothing size!</strong><br />";
}
?>
<div class="size" style="width 100px; float:left; height 100px; margin:0px">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Select a size: <br />
<label class="one"> <input type="radio" name="size" value="Extra Small"
<?php
if ($_POST['size'] == 'Extra Small') {
echo "checked";
}
?>
/>Extra Small</label><br />
<label class="one"> <input type="radio" name="size" value="Small"
<?php
if ($_POST['size'] == 'Small') {
echo "checked";
}
?>
/>Small</label><br />
<label class = "one"> <input type="radio" name="style" value="Medium"
<?php
if ($_POST['size'] == 'Medium') {
echo "checked";
}
?>
/>Medium</label><br />
<label class="one"> <input type="radio" name="size" value="Large"
<?php
if ($_POST['size'] == 'Large') {
echo "checked";
}
?>
/>Large</label><br />
<label class="one"> <input type="radio" name="size" value="Extra Large"
<?php
if ($_POST['size'] == 'Extra Large') {
echo "checked";
}
?>
/>Extra Large</label><br />
<label class="one"> <input type="radio" name="size" value="2X Large"
<?php
if ($_POST['size'] == '2X Large') {
echo "checked";
}
?>
/>2X Large</label>
</div>
我希望它们水平地彼此相邻显示,这样看起来不错。
解决方案
只需为您的错误添加表..
<?php
if(($_POST['style'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
echo "<table> <tr> <td> <strong>Please select a clothing style!</strong> </td> </tr> </table>";
}
?>
<?php
if(($_POST['size'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
echo "<table> <tr> <td> <strong>Please select a clothing size!</strong></td> </tr> </table>";
}
?>
<div class="style" style="width 100px; float:left; height 100px; margin:0px;">
<!-- this code asks the suer what clothing style they like. They have a lot of options. The code is like the gender code -->
Select a style: <br />
<label> <input type="radio" name="style" value="Casual"
<?php
if ($_POST['style'] == 'Casual') {
echo "checked";
}
?>
/>Casual</label><br />
<label> <input type="radio" name="style" value="Athletic"
<?php
if ($_POST['style'] == 'Athletic') {
echo "checked";
}
?>
/>Athletic</label><br />
<label> <input type="radio" name="style" value="Vintage"
<?php
if ($_POST['style'] == 'Vintage') {
echo "checked";
}
?>
/>Vintage</label><br />
<label> <input type="radio" name="style" value="Formal"
<?php
if ($_POST['style'] == 'Formal') {
echo "checked";
}
?>
/>Formal</label><br />
<label> <input type="radio" name="style" value="Streetwear"
<?php
if ($_POST['style'] == 'Streetwear') {
echo "checked";
}
?>
/>Streetwear</label><br />
<label> <input type="radio" name="style" value="Rocker"
<?php
if ($_POST['style'] == 'Rocker') {
echo "checked";
}
?>
/>Rocker</label>
</div>
<div class="size" style="width 100px; float:left; height 100px; margin:0px">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Select a size: <br />
<label class="one"> <input type="radio" name="size" value="Extra Small"
<?php
if ($_POST['size'] == 'Extra Small') {
echo "checked";
}
?>
/>Extra Small</label><br />
<label class="one"> <input type="radio" name="size" value="Small"
<?php
if ($_POST['size'] == 'Small') {
echo "checked";
}
?>
/>Small</label><br />
<label class = "one"> <input type="radio" name="style" value="Medium"
<?php
if ($_POST['size'] == 'Medium') {
echo "checked";
}
?>
/>Medium</label><br />
<label class="one"> <input type="radio" name="size" value="Large"
<?php
if ($_POST['size'] == 'Large') {
echo "checked";
}
?>
/>Large</label><br />
<label class="one"> <input type="radio" name="size" value="Extra Large"
<?php
if ($_POST['size'] == 'Extra Large') {
echo "checked";
}
?>
/>Extra Large</label><br />
<label class="one"> <input type="radio" name="size" value="2X Large"
<?php
if ($_POST['size'] == '2X Large') {
echo "checked";
}
?>
/>2X Large</label>
</div>
推荐阅读
- javascript - 我应该使用 nginx 重写 Nuxt.js
- c - Int main() 或只是 main()
- c# - 使用串行端口,我得到一个错误:尝试读取或写入受保护的内存
- python - 将值保存在数组中的循环出错:IndexError:列表索引超出范围
- python - Python:确定存储在数据框中的三个文本字符串是否有任何共同的单词
- javascript - 即使在使用 JavaScript 更改源之后,WordPress 视频也会重复
- html - 如何在表单中发布一个空选项
- ios - 图像压缩目标 c
- python - 使用 firefox geckodriver 在 selenium 中代理
- apk - Android Studio 3 构建带有 NOX 文件类型的 APK