我正在尝试创建联系表单,但表单本身正在运行,但是每次我提交回复消息时,“提交”按钮都会不断移出位置。我虽然将提交按钮放在了while循环之外,但它仍然像在while循环内一样
我试图将括号移到该位置,但似乎无济于事。我正在考虑使用固定位置,但我仍然认为我应该能够使它与绝对或相对位置一起使用。我将其更改为相对,但按钮未显示为相对位置
这是我的主要代码:
<?php
include_once 'navbar.php';
if(!isset($_SESSION['u_uid'])) {
header("Location: index.php?medical_premium_users=notlogin");
exit();
} else {
include_once 'includes/dbh.php';
$sql = "SELECT * FROM contact_form;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck < 1) {
echo '<div class="no_enquiries">There are no enquiries yet!</div>';
}
echo '<form action="medical_enquiries_reply_process.php" method="POST">
<table class="medical_enquiries_reply">
<tr>
<th colspan="3" class="update_title">Welcome to the Administrator\'s Enquiries Reply Section</th>
</tr>';
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr><th>Ticket:</th><td>'.$row['ticket'].'<input type="hidden" name="ticket" value="',htmlspecialchars($row['ticket']),'"></td></tr>
<tr><th>Username:</th><td>'.$row['user_uid'].'</td></tr>
<tr><th>First Name:</th><td>'.$row['first_name'].'</td></tr>
<tr><th>Last Name:</th><td>'.$row['last_name'].'</td></tr>
<tr><th>E-Mail:</th><td>'.$row['email'].'</td></tr>
<tr><th>Subject:</th><td>'.$row['subject'].'<input type="hidden" name="subject" value="',htmlspecialchars($row['subject']),'"></td></tr>
<tr><th>Message:</th><td>'.$row['message'].'</td></tr>
<tr><th>Date of Message:</th><td>'.$row['date_sent'].'</td></tr>
<tr><th>Message Reply:</th><td>'.$row['message_reply'].'</td></tr>
<tr><th>Date of Reply:</th><td>'.$row['date_reply'].'</td></tr>
<tr><th>Solved Status:</th><td>'.$row['solved'].'</td></tr>';
}
echo '</tr>
<th>Reply Section</th><td class="reply"><textarea name="reply" placeholder="Message Reply"></textarea></td>
</tr>
<tr>
<th>Has this been resolved?</th><td colspan="2"><input type="radio" name="resolve" value="No"><label id="no">No</label><input type="radio" name="resolve" value="Yes"><label id="yes">Yes</label></td>
</tr>
<tr>
<th>Reply</th><td colspan="2"><input type="submit" name="submit" value="Reply"></td>
</tr>
</table>
</form>';
}
}
?>
This is my CSS code:
.medical_enquiries_reply input[type="submit"] {
position: relative;
top: 346em;
left: 41em;
width: 10%;
height: 40px;
border:none;
background-color: #222;
font-family: arial;
font-size: 16px;
color: #fff;
cursor:pointer;
border-radius: 1em;
white-space: nowrap;
}
答案 0 :(得分:0)
在此行将th更改为td
<th>Reply</th><td colspan="2"><input type="submit" name="submit" value="Reply"></td>
其他所有以th开头并以td大声笑结尾的行
TH仅用于表头,应由coresponding标签关闭。
表结构应如下所示
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
看看第一个tr如何包含th,所有其他花序都为td?
您面临的问题是由您的HTML结构引起的。浏览器没有关闭标签,而是建立了一个奇怪的表。由于标签未正确关闭,因此尝试通过自己关闭标签来呈现视图,但他没有在合适的位置将其关闭。
我还注意到您的HTML中还有多余的TR关闭标签
第一个应该是tr开头
因此工作表如下所示:
<form action="medical_enquiries_reply_process.php" method="POST">
<table class="medical_enquiries_reply">
<tr>
<th colspan="3" class="update_title">Welcome to the Administrator\'s Enquiries Reply Section</td>
</tr>
<tr><td>Ticket:</td><td>'.$row['ticket'].'<input type="hidden" name="ticket" value="',htmlspecialchars($row['ticket']),'"></td></tr>
<tr><td>Username:</td><td>'.$row['user_uid'].'</td></tr>
<tr><td>First Name:</td><td>'.$row['first_name'].'</td></tr>
<tr><td>Last Name:</td><td>'.$row['last_name'].'</td></tr>
<tr><td>E-Mail:</td><td>'.$row['email'].'</td></tr>
<tr><td>Subject:</td><td>'.$row['subject'].'<input type="hidden" name="subject" value="',htmlspecialchars($row['subject']),'"></td></tr>
<tr><td>Message:</td><td>'.$row['message'].'</td></tr>
<tr><td>Date of Message:</td><td>'.$row['date_sent'].'</td></tr>
<tr><td>Message Reply:</td><td>'.$row['message_reply'].'</td></tr>
<tr><td>Date of Reply:</td><td>'.$row['date_reply'].'</td></tr>
<tr><td>Solved Status:</td><td>'.$row['solved'].'</td></tr>
<tr>
<td>Reply Section</td><td class="reply"><textarea name="reply" placeholder="Message Reply"></textarea></td>
</tr>
<tr>
<td>Has this been resolved?</td><td colspan="2"><input type="radio" name="resolve" value="No"><label id="no">No</label><input type="radio" name="resolve" value="Yes"><label id="yes">Yes</label></td>
</tr>
<tr>
<td>Reply</td><td colspan="2"><input type="submit" name="submit" value="Reply"></td>
</tr>
</table>
</form>