Are there any potential security risks associated with increasing the limit of data retrieval using a button in PHP?

Increasing the limit of data retrieval using a button in PHP can potentially lead to security risks such as SQL injection attacks if user input is not properly sanitized. To mitigate this risk, it is important to validate and sanitize user input before using it in database queries.

// Validate and sanitize the limit parameter before using it in a database query
$limit = isset($_GET['limit']) ? intval($_GET['limit']) : 10;
$limit = ($limit > 0 && $limit <= 100) ? $limit : 10;

// Use the sanitized limit parameter in the database query
$query = "SELECT * FROM table_name LIMIT $limit";
// Execute the query and fetch the results