"Transport" variable "into" php

Hello!
Please, how to transport the z2 value to php part of the code?
Many thanks!

If you want to transfer the Data from Javascript into PHP.
Use jSON.
Don’t forget to google.

Hello I wrote this but says it does nto recognise “m” index!

http://pastebin.com/GZx1657m

p.s. Please, how can I get code here ?
Many thanks!

This here gives error , does not recognise ‘m’ ???

     <body>



      <form id="frm1" action="form_processor.php" method="post">
     Input number of the rows: <input type="text" value=" " name="m">
     </form>

     <script>
         function functionm(){
         var z1=document.forms["frm1"];
          var z2=z1.elements[0].value;
          alert(z2);
     }
    </script>

     <button onclick="functionm()">Number of the rows: </button>

     <?php
         $a=$_POST["m"];
          $b=2;
          echo "<table border='1'><br />";

          for ($row = 0; $row < $a; $row ++) {
              echo "<tr>";

          for ($col = 1; $col <= $b; $col ++) {
                echo "<td>", ($col + ($row *$b)), "</td>";
        }

            echo "</tr>";
         }

         echo "</table>";

         ?>
         </body>

The “transport” from JS (in the client’s browser) to PHP (in the server) is done over TCP and in the case of a normal form, over HTTP(S). If you happen to not understand what I just wrote, then I would suggest you should start learning the basics about how client browsers communicate with servers over the Internet. To get you started.

http://php.net/manual/en/faq.html.php

Scott

You don’t need JavaScript to do that.
First of all, learn how to proccess forms with PHP.
Here are sample tutorial

Helo, I am getting “strange” error here: says that “file ends onunexpected place” ?
Why?
btw.i work on phpfiddle

Many thanks!!!

<form id="frm1" action="form_processor.php" method="post">
Input number of the rows: <input type="text" value=" " name="m">
</form>




   <?php
       if ($_SERVER["REQUEST_METHOD"] == "POST") {
           // collect value of input field
           $name = $_POST['fname']; 

            $a=$_POST["m"];
            $b=2;

           echo "<table border='1'><br />";

           for ($row = 0; $row < $a; $row ++) {
               echo "<tr>";

           for ($col = 1; $col <= $b; $col ++) {
               echo "<td>", ($col + ($row *$b)), "</td>";
           }

           echo "</tr>";
            }

           echo "</table>";

            ?>


              </body>

Unknown index “m” again…

   <form id="frm1" action="form_processor.php" method="post">
        Input number of the rows: <input type="text" value=" " name="m">
   </form>




    <?php
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         // collect value of input field
         $a = $_POST['m']; 
        }





          $a=$_POST["m"];
          $b=2;
              echo "<table border='1'><br />";

          for ($row = 0; $row < $a; $row ++) {
          echo "<tr>";

         for ($col = 1; $col <= $b; $col ++) {
         echo "<td>", ($col + ($row *$b)), "</td>";
         }

        echo "</tr>";
       }

        echo "</table>";

        ?>

Hello! I tried with and without this

          /*if ($_SERVER["REQUEST_METHOD"] == "POST") {
           // collect value of input field
           $a = $_POST['m']; 
           }*/

and I wonder what it acualy serves for???

I think the / a problem is because the form is sending a text. String, $row is an Integer.

When would Integer be less than String?

PHP automatically converts types when you compare string with a number

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.