$sql = "SELECT id, name, email FROM users"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "id: " . $row["id"]. " - Name: " . $row["name"]. " - Email: " . $row["email"]. "This code will retrieve data from the "users" table in a mysSQL database. It uses the `mysqli_query()` function to execute the SQL query and store the result set in `$result`. The `mysqli_num_rows()` function is used to check whether there are any rows returned by the query. If there are, the `mysqli_fetch_assoc()` function is used to retrieve each row from the result set and store it in the `$row` variable. The data is then outputted to the browser. Package Library: The package library used in this example is the MySQLi extension, which provides an object-oriented interface for working with MySQL databases.
"; } } else { echo "0 results"; }