How can I fill two table columns simultaneously with data from one input field in PHP?
To fill two table columns simultaneously with data from one input field in PHP, you can simply assign the input field value to two separate variables and then insert those variables into the respective columns in the database table.
<?php
// Assuming you have retrieved the input field value and connected to your database
// Assign the input field value to two variables
$inputValue = $_POST['input_field'];
$column1Value = $inputValue;
$column2Value = $inputValue;
// Insert the values into the database table
$sql = "INSERT INTO your_table_name (column1, column2) VALUES ('$column1Value', '$column2Value')";
if ($conn->query($sql) === TRUE) {
echo "Data inserted successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
// Close the database connection
$conn->close();
?>