Home > Enterprise >  width and height of an html table cells in php
width and height of an html table cells in php

Time:05-22

//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>";
?>

CodePudding user response:

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:

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>";
}
  • Related