Question about retrieving individual records from table

Hi everyone,

I have a column in my table which includes a number of cities. I might have 10 rows with the name ‘London’ and 5 rows with the name ‘New York’. How can I print out all of the cities without the same names repeating themselves? So, one row for each individual city.

<?php
require (MYSQL);
$q = "SELECT city FROM messages";
    $r = @mysqli_query($dbc, $q);
    $num = mysqli_num_rows($r);
    if ($num > 0) {
 while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {

print'<p>'.$row['city'] . '</p>';
 }
    }

?>  

Thank you in advance!

SELECT DISTINCT city FROM messages

Hi Rudy,

brilliant! Thank you.

Regards