Jump to content

Gzyms

New Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Gzyms

  1. PHP Tree

     

     

     Hi Guys,

     

    I am a beginner so my question may seem simple wink.gif

     

    I have a "tree", I want to make it possible to change tree's size when someone enters number of lines into the box "Send".

     

    Code:

     

     

    PHP Code:

     

    <html>
    
    <body>
    
    <form method="GET" action="tree.php">
    
    <label for="numberofLines" value="shownumberofLines">
    <input type="text" name="numberofLines">
    <input type="submit" value="Send">
    </form>
    <table>
    
    <?php
    
     $numberofLines = !empty($_GET['numberofLines']) ? $_GET['numberofLines'] : 5;   
     var_dump($numberofLines);
        
      
        $a = '<td style="background-color:white"> </td>';
        $b = '<td style="background-color:green"> </td>';  
        $c = '<td style="background-color:brown"> </td>';  
        $d = '<td style="background-color:yellow"> </td>'; 
        
      for ($i = 0; $i < 4; $i++) {
          echo $a;
          }
      for ($i = 0; $i < 1; $i++)  {
          echo $d;
          }
      for ($i = 0; $i < 2; $i++)  {
          echo $a;
          }          
          
      echo "<tr>";    
      for ($i = 0; $i < 2; $i++) {
          echo $a;
          }   
          
      for ($i = 0; $i < 5; $i++) {
          echo $b;
          }         
          
        echo "</tr>";
        
    echo "<tr>";    
      for ($i = 0; $i < 0; $i++) {
          echo $a;
          }   
          
      for ($i = 0; $i < 9; $i++) {
          echo $b;
          }         
          
      echo "</tr>";  
      
      echo "<tr>";
    for ($i = 0; $i < 4; $i++) {
          echo $a;
          }
      for ($i = 0; $i < 1; $i++)  {
          echo $c;
          }        
    echo "</tr>";
                
    ?>
      </table>
    </body>
     

     

     

     

    Thank You in advance!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.