What are the best practices for passing parameters via GET in PHP when editing data in a table?

When passing parameters via GET in PHP to edit data in a table, it is important to properly sanitize and validate the input to prevent SQL injection attacks. One common practice is to use prepared statements with placeholders to securely pass parameters to the database query. Additionally, it is recommended to use htmlentities() or htmlspecialchars() functions to prevent cross-site scripting attacks.

// Example of passing parameters via GET to edit data in a table
$id = $_GET['id']; // Assuming 'id' is the parameter containing the record ID

// Sanitize the input
$id = filter_var($id, FILTER_SANITIZE_NUMBER_INT);

// Prepare the SQL query using a prepared statement
$stmt = $pdo->prepare("UPDATE table SET column = :value WHERE id = :id");
$stmt->bindParam(':value', $value);
$stmt->bindParam(':id', $id);

// Execute the query
$stmt->execute();