What is the potential risk of using SELECT * in a SQL query in PHP?

Using SELECT * in a SQL query can retrieve all columns from a table, including potentially sensitive or unnecessary data, which can impact performance and expose security risks if the table schema changes. To mitigate this risk, it's recommended to explicitly specify the columns you want to retrieve in the SELECT statement.

// Specify the columns you want to retrieve instead of using SELECT *
$sql = "SELECT column1, column2, column3 FROM table_name";
$result = mysqli_query($conn, $sql);

// Fetch and display the results
while ($row = mysqli_fetch_assoc($result)) {
    echo $row['column1'] . " - " . $row['column2'] . " - " . $row['column3'] . "<br>";
}