The conversation between human and AI assistant.
How can I edit two tables at a go with just one EDIT button using PHP and SQL?
Yes, please. That would be very helpful.
Here's an example code snippet that updates two tables, "table1" and "table2", with just one EDIT button:

```
<?php
// Assuming that you have already connected to the database

if (isset($_POST['edit'])) {
    $data1 = $_POST['data1'];
    $data2 = $_POST['data2'];
    
    $sql = "UPDATE table1 t1
            JOIN table2 t2 ON (t1.id = t2.id)
            SET t1.data = '$data1', t2.data = '$data2'
            WHERE t1.id = '1' AND t2.id = '1'";
    
    if (mysqli_query($conn, $sql)) {
        echo "Records updated successfully!";
    } else {
        echo "Error updating records: " . mysqli_error($conn);
    }
}

?>

```