Showing posts with label Php. Show all posts
Showing posts with label Php. Show all posts

Wednesday

Create Dynamic input text fields in html using PHP

0 comments
      Sometimes we need to create input fields in the form according to the need of users. Let it be dynamic,If you don't know the no.of fields required exactly. In this tutorial we see how to generate a dynamic input field  & how to print those values in a for loop using php.
Grab latest version php.net.

Get the Number of text fields to generate & pass it to main.php

   <form action="main.php" method="post">
        No.of Text fields <input type="text" name="nos" />
       <input type="submit" value="Submit" />
   </form>

  • $nos going to be no.of times the for loop iterate.

Tuesday

Get dynamic variable & print in PHP

0 comments
In this tutorial we will see how to get N number of dynamic variables and print it using php. Each value is accessed using a for loop.

if(isset())
  •    It is used to check for null values
  •    $nos is no.of text fields generated,so for loop used to get values of generated fields.
  •    'c'.$i  ->  become c1 at 1st iteration and c2,c3,c4 ...and so on.

     <?php

            if(isset($_POST['nos']))
               $nos = $_POST['nos'];

            $techie=0;
            for($i=1;$i<= $nos;$i++)
                 {
                    $techie = $_POST['c'.$i] ;
                     echo "$techie";
    
                 }

        ?>




_________________________________________________________________________________

Don't Forget To Join US Our Community
×
blogger