php - 如何使用表格对齐输入字段

标签 php html css mysql html-table

我在调整 HTML 表单中输入字段的宽度时遇到了问题。我谷歌了一下,在 Stack Overflow 网站上找到了一些解决方案。我创建了一个表并将输入字段放入其中。它解决了我的问题,但我不知道为什么整个表格现在显示在页面底部。我正在分享我的程序的一部分。请检查并指导我。

include 'connect.php';

//      $select_query=          'Select * from category';
//      $select_query_run =     mysql_query($select_query);

        echo "<div id='line' >
               <div id='form'>";

echo "  
    <form action='insert_product.php' method='POST' enctype='multipart/form-data' ></br></br>
    <table border=1>
    <tr>
    <td>
    <label>Product Name:</label> </td>  <td><input type='text' name='product_name'  />*Required</td></tr></br> </br>

    <tr><td><label>Item No:</label></td> <td><input type='text' name='item_no' ></td></tr></br></br>

    <tr><td>Recipient   </td>   <td> <input type='text' name='recipient' ></td></tr> </br></br>

<tr><td>    Total Carat Weight</td> <td><input type='text' name= 'total_carat_weight' ></td></tr></br></br>

<tr><td>    Metal </td><td><input type='text' name='metal' ></td></tr></br></br>

<tr><td>    Stone Shape </td><td><input type='text' name='stone_shape' ></td></tr></br></br>

<tr><td>    Stone Type</td><td> <input type='text' name='stone_type'></td></tr> </br></br>

<tr><td>    Stone Setting</td><td> <input type='text' name='stone_setting'></td></tr> </br></br>

<tr><td>    Wastage </td><td><input type='text' name='wastage'></td></tr></br></br>

<tr><td>    Retail_price </td><td><input type='text' name='retail_price' ></td></tr></br></br>

<tr><td>    Actual Price: </td><td> <input type= 'text' name= 'price'  /></td></tr>*Required</br> </br>

<tr><td>    Description:</td><td><input type='text' name='description'  /></td></tr></br></br>

<tr><td>    Image1:</td><td> <input type='file' name= 'image' ></td></tr> *Required</br></br>

<tr><td>    Image2:</td><td> <input type='file' name= 'image2' ></td></tr></br></br>

<tr><td>    Image3:</td><td> <input type='file' name= 'image3' ></td></tr></br></br></table>    ";




/*------------------
Drop Down List Start
------------------  */      


        echo "<select name='category'>";

            $select_query=          'Select * from category';
            $select_query_run =     mysql_query($select_query);

            $sub_category_query=    "Select * from sub_categories";
            $sub_query_run=         mysql_query($sub_category_query);



        while   ($select_query_array=   mysql_fetch_array($select_query_run) )
        {

                echo "<option value='".$select_query_array['category_id']."' >".
                htmlspecialchars($select_query_array["name"]).

                        "<option value='".$sub_query_run['sub_category_id']."'  >" .
                        htmlspecialchars($sub_query_run['sub_category_name']).   "</option>".

                "</option>";




            }
            echo "</br>";

     $selectTag= "</br><input type='submit' value='Insert Product'  /></select></form>";

     echo "</div></div>";

     echo $selectTag;

这是我的 CSS 文件。

#line
{
height: 900px; /*Specify Height*/
width:  790px; /*Specify Width*/
border: 1px solid #d5dfea; /*Add 1px solid border, use any color you want*/
background-color: #fafbfd; /*Add a background color to the box*/
text-align:left; /*Align the text to the center*/
/*margin: auto;*/
margin:10px;

box-shadow: 10px 5px 5px  #888888;
padding:20px;
}

#form
{
    margin :auto;
    padding:inherit;
    font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;


}

input, select, textarea {
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
}

最佳答案

你的 </br>元素是假的。

首先,如果您尝试使用兼容的 xhtml 进行编码,您需要 <br />而不是你拥有的。

其次,不清楚换行符在行之间的表定义中的作用。

关于php - 如何使用表格对齐输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17795351/

相关文章:

PHP画廊中的CSS布局

css - 有没有办法让背景图像在 moz-linear-gradients 上渲染

php - ElasticSearch-用元数据排除匹配

html - IE7 宽度 :auto issue

php - 如何在 PHP 中调用函数

html - css counter-increment 跳过 :before 时不需要的重置

html - Canvas 默认大小

javascript - 溢出隐藏不会文字换行

php - 为什么 PHP 的自动加载功能在 CLI 模式下不起作用?

php - 我的 AJAX 表单不会提交并返回响应