简体   繁体   English

php中html表格单元格的宽度和高度

[英]width and height of an html table cells in php

//sorry for the bad code and the French I'm new, all I want is to make the user chose the width and height of the cells please make it simple as possible. //抱歉代码不好,法语我是新手,我只想让用户选择单元格的宽度和高度,请尽可能简单。

<form method="POST">
    Nombre de Lignes: <input type="text" name="lign">
    Taille de Bordure: <input type="text" name="border">
    Nombre de Colonnes: <input type="text" name="ncol">
    Largeur de Colonnes: <input type="text" nom="widh">
    Longueur de Colonnes: <input type="text" nom="heig">
    <input type="submit">
</form>
<?php
     if ($_SERVER["REQUEST_METHOD"] == "POST"){
          $l = $_POST["lign"];
          $b = $_POST["border"];
          $c = $_POST["ncol"];
          $widh = $_POST["widh"];
          $heig = $_POST["heig"];
          echo "<table border=$b cellspacing=\"0\">";
               for ($i = 1; $i <=$l; $i++){
                   echo "<tr>";
                   for ($j = 1;$j <= $c; $j++){
                        echo ("<td width='$widh' height='$heig'>&nbsp;</td>");
                    }
                   echo "</tr>";
                }
          echo "</table>";
?>

Update the input attributes correctly, 'name':正确更新输入属性,“名称”:

Largeur de Colonnes: <input type="text" name="widh">
Longueur de Colonnes: <input type="text" name="heig">

PHP Codes should be like this: PHP 代码应该是这样的:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $l = $_POST["lign"];
    $b = $_POST["border"];
    $c = $_POST["ncol"];
    $widh = $_POST["widh"];
    $heig = $_POST["heig"];
    echo "<table border='$b' cellspacing='0'>";
    for ($i = 1; $i <= $l; $i++) {
        echo "<tr>";
        for ($j = 1; $j <= $c; $j++) {
            echo "<td width='$widh' height='$heig'>&nbsp;</td>";
        }
        echo "</tr>";
    }
    echo "</table>";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM