How can the ID of a newly inserted record in PHP be retrieved for later use as a GET variable in a link?

When inserting a new record into a database using PHP, you can retrieve the ID of the newly inserted record by using the `mysqli_insert_id()` function. This function returns the auto-generated ID that was assigned to the last inserted row. You can then store this ID in a variable and use it as a GET variable in a link for later use.

// Insert new record into database
// Assuming $conn is your database connection
mysqli_query($conn, "INSERT INTO your_table (column1, column2) VALUES ('value1', 'value2')");

// Get the ID of the newly inserted record
$new_record_id = mysqli_insert_id($conn);

// Use the ID as a GET variable in a link
echo '<a href="your_page.php?id=' . $new_record_id . '">Link</a>';