PHP - MYSQL MOVE RECORDS FROM TABLE TO OTHER TABLE

Hank Greenberg

Total Post:12

Points:84
Posted by  Hank Greenberg
PHP 
PHP
 1743  View(s)
Ratings:
Rate this:
Hi Mindstickians,

I want to insert a record from first query i means the rows make then with seconds query to insert. can some one help me please

if ( isset($_GET['del']) ) {
    $id = $_GET['del'];
    $result = mysqli_query($con,"SELECT * FROM products WHERE id='$id'");
    while($row = mysqli_fetch_array($result))
    {
        echo $row['username'] . " " . $row['size'];
        echo "<br>";
    }
    $sql_move = mysqli_query($con,"INSERT INTO history (username, serial, image,   arrive,size)");
    $sql = mysqli_query($con,"DELETE FROM products WHERE id='$id'");
    echo "its deleted";
}
?>

Thanks in advance.
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: php - mysql move records from table to other table

    Try as following!

    First of all, you're trying to access $row from outside the loop, where it doesn't exist. Put the insert/delete lines in the loop, and then proceed.

    Second, you're not inserting the values.

    $sql_move = mysqli_query($con, "INSERT INTO history (username, serial, image,   arrive,size) VALUES ('{$row['username']}', '{$row['serial']}', '{$row['image']}', '{$row['arrive']}', '{$row['size']}'");

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!