0

我在 .php 中尝试使用的表单存在问题

我在表格中使用表格来格式化我希望表格的外观。表单工作正常。但是当我加载页面时,页面顶部有一个巨大的空白,但我不知道它为什么会在那里。我已经尝试在网络浏览器中查看源代码,并且没有 html 空白字符或任何异常。这是我的代码:

<?php
$strRequester  = $_SERVER['PHP_SELF'];
echo "<div align=center>\n";
echo "<form name='SandwichOrder' action='$strRequester' method='POST'>\n";
####Bread####
echo "<table>\n";
echo "<tr><td bgcolor='CCCCCC'><input type='radio' name='size' value='whole'><b>Whole Sandwich</b></td>\n";
echo "<td bgcolor='CCCCCC'><input type='radio' name='size' value='half'><b>Half Sandwich</b></td></tr>\n";
echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Roll/Bread:</b></td><td></td></tr><br>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='whiteroll'>White French Roll</td><br>\n";
echo "<td><input type='radio' name='bread' value='sourroll'>Sour Dough Roll</td><br>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='wheatroll'>Wheat French Roll</td><br>\n";
echo "<td><input type='radio' name='bread' value='dutchcrunch'>Dutch Crunch</td><br>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='nyrye'>New York Rye</td>\n";
echo "<td><input type='radio' name='bread' value='soursliced'>Sour Dough Bread</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='wheatsliced'>100% Whole Wheat Bread</td>\n";
echo "</tr>\n";
####Meat####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Meat:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='roastbeef'>Roast Beef</td>\n";
echo "<td><input type='radio' name='meat' value='turkey'>Turkey</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='everroastchicken'>EverRoast Chicken</td>\n";
echo "<td><input type='radio' name='meat' value='ham'>Ham</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='salami'>Salami</td>\n";
echo "<td><input type='radio' name='meat' value='pastrami'>Pastrami</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='tune'>Tuna</td>\n";
echo "<td><input type='radio' name='meat' value='chickensalad'>Chicken Salad\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='veggiepatty'>Veggie Patty</td>\n";
echo "<td><input type='radio' name='meat' value='vegetarian'>Vegetarian</td>\n";
echo "</tr>\n";
####Cheese####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Cheese:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='cheddar'>Cheddar Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='swiss'>Swiss Cheese</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='pepperjack'>Pepper Jack Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='american'>American Cheese</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='provolone'>Provolone Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='none'>No Cheese</td>\n";
echo "</tr>\n";
####Condiments####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Condiments:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='mayonnaise' value='mayonnaise'>Add Mayonnaise</td>\n";
echo "<td><input type='checkbox' name='mustard' value='mustard'>Add Mustard</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='lettuce' value='lettuce'>Add Lettuce</td>\n";
echo "<td><input type='checkbox' name='pickles' value='pickles'>Add Pickles</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='tomato' value='tomato'>Add Tomato</td>\n";
echo "<td><input type='checkbox' name='peppers' value='peppers'>Add Peppers</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='onion' value='onion'>Add Onion</td>\n";
echo "<td><input type='checkbox' name='olives' value='olives'>Add Olives</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='salt' value='salt'>Add Salt</td>\n";
echo "<td><input type='checkbox' name='suboil' value='suboil'>Add Sub Oil</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='pepper' value='pepper'>Add Pepper</td>\n";
echo "<td><input type='checkbox' name='avocado' value='avocado'>Add Avocado $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='sprouts' value='sprouts'>Add Sprouts $0.50</td>\n";
echo "</tr>\n";
####Extras####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Extra Meat or Cheese:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eroastbeef' value='eroastbeef'>Extra Roast Beef $1.00</td>\n";
echo "<td><input type='checkbox' name='eturkey' value='eturkey'>Extra Turkey $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eeverroastchicken' value='eeverroastchicken'>Extra EverRoast Chicken $1.00</td>\n";
echo "<td><input type='checkbox' name='eham' value='eham'>Extra Ham $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='esalami' value='esalami'>Extra Salami $1.00</td>\n";
echo "<td><input type='checkbox' name='epastrami' value='epastrami'>Extra Pastrami $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='etuna' value='etuna'>Extra Tuna $1.00</td>\n";
echo "<td><input type='checkbox' name='echickensalad' value='echickensalad'>Extra Chicken Salad $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='ebacon' value='ebacon'>Extra Bacon $1.00</td>\n";
echo "<td><input type='checkbox' name='eveggiepatty' value='eveggiepatty'>Extra Veggie Patty $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='evegetarian' value='evegetarian'>Extra Vegetarian $1.00</td>\n";
echo "<td><input type='checkbox' name='echeddar' value='echeddar'>Extra Cheddar $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eamerican' value='eamerican'>Extra American $0.50</td>\n";
echo "<td><input type='checkbox' name='eswiss' value='eswiss'>Extra Swiss Cheese $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eprovolone' value='eprovolone'>Extra Provolone Cheese $0.50</td>\n";
echo "<td><input type='checkbox' name='epepperjack' value='epepperjack'>Extra Pepper Jack Cheese $0.50</td>\n";
echo "</tr>\n";
echo "</table>\n";
####Name/Instructions####
echo "<b>Add your Name or Special Instructions</b><br>\n";
echo "<input type='text' name='instructions' value='' size='50'><br>\n";
echo "<input type='SUBMIT' name='SUBMIT' value='Add to Order'><br>\n";
echo "<input type='button' name='CANCEL' value='Cancel Item'>\n";
echo "</form>";
echo "</div>\n";
?>

我也尝试将整个表格放入表格中,但这也无济于事。任何建议都会很棒。我对 .php 和 html 还很陌生,所以在解决这个问题时我什至不知道从哪里开始。

4

1 回答 1

1

您是否将表单回显到 html 文档中?IE

<!doctype html>
<html>
<head>
<title>Title of the document</title>
</head>

<body>
 YOUR FORM HERE
</body>

</html>

( http://www.w3schools.com/tags/tag_body.asp )

您的 div 或 html 上可能有默认样式。在你的 CSS 中尝试:

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
}

div {
   margin: 0;
}
于 2013-10-27T20:39:32.020 回答