$cities = "Amsterdam|Rotterdam|Den Haag"
$results = mysql_query("SELECT * FROM messages WHERE content REGEXP '$cities'");
The above code works great, but if $cities is empty, nothing is selected. I’d like to select all rows if $cities has no value. How can I achieve that? Thanks!
You will need to use a conditional in your php, which removes the where clause when your
$citiesvariable is empty. Alternatively, you can use a regex that matches everything like/^/, but it’s not particularly elegant.