kangjacob 2023-03-14 08:21 采纳率: 96.8%
浏览 8
已结题

php生成的表格为何和表头无法对齐?

写了下面的代码,echo这部分的代码和表头为何无法对齐?有谁知道能告诉我么?谢谢!


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
    <style type="text/css">
    
        table{
            border: 1px solid skyblue;
        }
        td{border:1px solid skyblue;
        }
    </style>
</head>

<body>
    <table>
    <tr> 
    <td>foodName名称</td>
    <td>food_temperature性</td>
    <td>foodScore性分数</td>
    <td>food_taste味</td>
    <td>food_tropism归经</td>
    <td>upOrdown升降</td>
    <td>inAir归气分</td>
    <td>inBlood归血分</td>
    <td>gall_bladder胆经</td>
    <td>liver肝经</td>
    <td>lung肺经</td>
    <td>large_intestine大肠经</td>
    <td>stomach胃经</td>
    <td>spleen脾经</td>
    <td>heart心经</td>
    <td>intestine小肠经</td>
    <td>bladder膀胱经</td>
    <td>kidney肾经</td>
    <td>pericardium心包经</td>
    <td>triple-energizer三焦经</td>
    <td>spicy</td>
    <td>sweet</td>
    <td>tasteless</td>
    <td>acid</td>
    <td>bitter</td>
    <td>salty</td>
    <td>edible_part</td>
    <td>water</td>
    <td>energy</td>
    <td>protein</td>
    <td>fat</td>
    <td>carbohydrate</td>
    <td>insoluble_fiber</td>
    <td>cholesterol</td>
    <td>ash</td>
    <td>total_vitaminA</td>
    <td>carotene</td>
    <td>retinol</td>
    <td>thiamine</td>
    <td>riboflavin</td>
    <td>nicotinic_acid</td>
    <td>vitaminC</td>
    <td>vitaminE</td>
    <td>calcium</td>
    <td>phosphorus</td>
    <td>potassium</td>
    <td>sodium</td>
    <td>magnesium</td>
    <td>iron</td>
    <td>zinc</td>
    <td>selenium</td>
    <td>copper</td>
    <td>manganese</td>
    <td>comment</td>
    <td>glycemic_index</td>
    <td>data_source</td>
    <td>food_id</td>
    </tr>
    
    <?php 
    $food_name=$_GET["food_name"];
    $sql="SELECT * FROM foodList_table WHERE foodName='".$food_name."'";
    require_once("../dataBase.php");
    $result=$conn->query($sql);
    if($result->num_rows>0){
        while($row=$result->fetch_assoc()){
            echo "";
            echo  "".$row["foodName"]."";
            echo  "".$row["food_temperature"]."";
            echo  "".$row["foodScore"]."";
            echo  "".$row["food_taste"]."";
            echo  "".$row["food_tropism"]."";
            echo  "".$row["upOrdown"]."";
            echo  "".$row["inAir"]."";
            echo  "".$row["inBlood"]."";
            echo  "".$row["gall_bladder"]."";
            echo  "".$row["liver"]."";
            echo  "".$row["lung"]."";
            echo  "".$row["large_intestine"]."";
            echo  "".$row["stomach"]."";
            echo  "".$row["spleen"]."";
            echo  "".$row["heart"]."";
            echo  "".$row["intestine"]."";
            echo  "".$row["bladder"]."";
            echo  "".$row["kidney"]."";
            echo  "".$row["pericardium"]."";
            echo  "".$row["triple-energizer"]."";
            echo  "".$row["spicy"]."";
            echo  "".$row["sweet"]."";
            echo  "".$row["tasteless"]."";
            echo  "".$row["acid"]."";
            echo  "".$row["bitter"]."";
            echo  "".$row["salty"]."";
            echo  "".$row["edible_part"]."";
            echo  "".$row["water"]."";
            echo  "".$row["energy"]."";
            echo  "".$row["protein"]."";
            echo  "".$row["fat"]."";
            echo  "".$row["carbohydrate"]."";
            echo  "".$row["insoluble_fiber"]."";
            echo  "".$row["cholesterol"]."";
            echo  "".$row["ash"]."";
            echo  "".$row["total_vitaminA"]."";
            echo  "".$row["carotene"]."";
            echo  "".$row["retinol"]."";
            echo  "".$row["thiamine"]."";
            echo  "".$row["riboflavin"]."";
            echo  "".$row["nicotinic_acid"]."";
            echo  "".$row["vitaminC"]."";
            echo  "".$row["vitaminE"]."";
            echo  "".$row["calcium"]."";
            echo  "".$row["phosphorus"]."";
            echo  "".$row["potassium"]."";
            echo  "".$row["sodium"]."";
            echo  "".$row["magnesium"]."";
            echo  "".$row["iron"]."";
            echo  "".$row["zinc"]."";
            echo  "".$row["selenium"]."";
            echo  "".$row["copper"]."";
            echo  "".$row["manganese"]."";
            echo  "".$row["comment"]."";
            echo  "".$row["glycemic_index"]."";
            echo  "".$row["data_source"]."";
            echo  "".$row["food_id"]."";
            echo  "";
            }
    }else{
            echo "没有记录哦";
        }
    ?>
        
    </table>
</body>
</html>

  • 写回答

2条回答 默认 最新

  • kangjacob 2023-03-14 11:04
    关注

    找到原因了,要这样写,结果echo 的时候写成了,都是平时太依赖编辑器了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月22日
  • 已采纳回答 3月14日
  • 创建了问题 3月14日

悬赏问题

  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA