What are the potential issues with using "SELECT *" in a MySQL query when fetching data in PHP?

Using "SELECT *" in a MySQL query can lead to performance issues and security vulnerabilities. It can retrieve unnecessary columns, leading to increased data transfer and processing time. To solve this issue, explicitly specify the columns you want to retrieve in the SELECT statement.

<?php
// Connect to the database
$connection = mysqli_connect("localhost", "username", "password", "database");

// Query with specified columns
$query = "SELECT column1, column2, column3 FROM table";

$result = mysqli_query($connection, $query);

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

// Close the connection
mysqli_close($connection);
?>