0
$user ='root';
    $pass = '';
    $db = 'sad';
    $con =mysqli_connect($host,$user,$pass,$db);

    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <title>ADMIN</title>
        <style>
        table,th,td
        {
        border: 1.5px solid black;
        }
        </style>
        <script>
            function approve()
            {
                <?php

                  $hide = $_POST['omg'];
                  $qwe = "INSERT INTO `enrolled` SELECT * FROM `new` WHERE `id` = '$hide' ";



                ?>


            }
        </script>
        </head>
    <body>
        <form method='POST'>
            <table width=500px >


                <?php 

                $sql = "SELECT * FROM New";
                $result = mysqli_query($con, $sql);
                if (mysqli_num_rows($result) > 0) {
                while($row = mysqli_fetch_assoc($result)) {

                echo "<form method='POST'><tr><td>ID: " . $row["id"]. "<br>FIRSTNAME: " . $row["fname"]. "<br>MIDDLENAME: " . $row["mname"]. "<br>LASTNAME : " . $row["lname"]. "<br>COURSE: " . $row["course"]. "<br>ADDRESS: " . $row["address"]. "<br>CONTACT: " . $row["contact"] . "<br><br><input type='text' name='omg' value=$row[id]> <input type='button' name= 'btn' value='Approve' onclick=approve()></td></tr></form>";

                }
                }
                else
                {
                    echo "No Request Sent!";
                }
                ?>



            </table>
        </form>
    </body>
    </html>

Can you guys help me ? the variable $hide does not contains any amount but my code states that $hide = $_POST['omg'] . omg is the name of the textbox and that textbox contains the id .

my code works if i erase the WHERE id= 'hide' , yet it will copy all data of the table 'new' to table 'enrolled'. but what i need is to copy a single row data in the table 'new' and transfer it to table 'enrolled' .

please help me . i already made so many trials. :(

zxc
  • 33
  • 5
  • you should check for errors via php and the queries; you have many and your developer console also – Funk Forty Niner Nov 19 '17 at 14:04
  • Um... You can't mix JavaScript and PHP like that. Essentially you're trying to get the value when the page loads, *before* the user has entered a value. When you check your logs, do so *between* loading the page and posting the form. See what's happening. Also look at the page source in your browser. See that you have an empty JavaScript function that doesn't do anything. – David Nov 19 '17 at 14:05

0 Answers0