【发布时间】:2021-02-01 04:25:26
【问题描述】:
我正在完成一个需要从服务器获得响应的学校项目,所以我编写了一些 php 代码。我已经把所有东西都与表格对齐,但是当我实现它时,我在代码中发现了一个巨大的差距。以前有没有人见过这个,我知道是标签导致了这个,但我不知道为什么他们一直把它搞砸,我试图移动它们,但它们里面的所有东西都没有运气。下面是这段代码的结果,
感谢您的帮助。 Code’s outcome
<?php
// create short variable names
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$state = $_POST['state'];
$outdate = $_POST['outdate'];
$indate = $_POST['indate'];
$numberofpeople = $_POST['numberofpeople'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$cardtype = $_POST['cardtype'];
$cardnum = $_POST['cardnum'];
$specialrequests = $_POST['specialrequests'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
?>
<html>
<body>
<?php
//displays what the user put in the form by using the vairables
echo "<table>";
echo '<h1>Thank you '.$fname.' '.$lname.' for your Reservation</h1><br>';
echo 'The following is the infomation you entered:<br></tr>';
echo "<tr><td>Number & Street</td><td>$address</td><br/</tr>";
echo "<tr><td>City</td><td>$city</td><br></tr>";
echo "<tr><td>ZipCode</td><td>$zip</td><br></tr>";
echo "<tr><td>State</td><td>$state</td><br></tr>";
echo "<tr><td>Check-In Date</td><td>$indate</td><br></tr>";
echo "<tr><td>Check-out Date</td><td>$outdate</td><br></tr>";
echo "<tr><td>Number of People</td><td>$numberofpeople</td><br></tr>";
echo "<tr><td>Phone</td><td>$phone</td><br></tr>";
echo "<tr><td>Email</td><td>$Email</td><br></tr>";
echo "<tr><td>Card-Type</td><td>$cardtype</td><br></tr>";
echo "<tr><td>Card-Number</td><td>$cardnum</td><br></tr>";
echo "<tr><td>Special Requests</td><td>$specialrequests</td><br></tr>";
echo "</table>";
?>
</body>
</html>
【问题讨论】:
-
代码有一些错误。这就是为什么你得到一个不正确的输出。您需要口头回答还是正确的代码作为答案
-
如果您能指出正确的方向,将不胜感激
-
希望这个答案对您有所帮助
-
您需要匹配起始标签和结束标签。带有
h1的行没有开头<tr>,但有结尾</tr>。然后,由于未知原因,</td><br/</tr>在td和tr之间出现了换行符,结果可能无法预测。尝试为初学者修复这些问题。
标签: php html html-table