Search returns no results

Hi.

I have an issue with a search in my php script.

When I want to do a search against a specific country then I get results for that country.
However if I do a search for All. I get no results found? If I then just do a search for the word destination I find everything?
I want to be able to get the same results if I search for All as I would if I searched for the word destination?
I also need to still keep the same functions that work already so if I search for a specific country I get the right results.
I hope that makes some sense…
I have attached the code below that I think is causing the problem.

Thanks for any help

<option value=“”>Destination</option>

  &lt;option value="all"&gt;All&lt;/option&gt;

  &lt;?php  do {  ?&gt;

  &lt;option value="&lt;?php echo $row_destinations['Country']?&gt;" &lt;?php if (!(strcmp($row_destinations['Country'], $cntfilter))) {echo "SELECTED";} ?&gt;&gt;&lt;?php echo $row_destinations['Country']?&gt;&lt;/option&gt;

  &lt;?php } while ($row_destinations = mysql_fetch_assoc($destinations)); $rows = mysql_num_rows($destinations);   if($rows &gt; 0) { mysql_data_seek($destinations, 0);  $row_destinations = mysql_fetch_assoc($destinations);  }?&gt;

I think we would need to see how you are building your SQL statement which contains the country code.

Is this what you need?

mysql_select_db($database_);

$query_destinations = “SELECT DISTINCT Country FROM location2 WHERE Country<>‘Belize’ ORDER BY Country ASC”;

$destinations = mysql_query($query_destinations, $dtw) or die(mysql_error());

$row_destinations = mysql_fetch_assoc($destinations);

$totalRows_destinations = mysql_num_rows($destinations)

Thanks

Try using a while loop, instead of do…while - your code runs one time before the mysql_fetch_assoc() is actually called to get a row from results.
Hope this helps!

That unfortunately is bad advice. Since he is calling mysql_fetch_assoc() prior to the loop, he needs to use a do-while instead of a while loop, otherwise, his results will never show the very first row (as shown when combining the OP’s first and second posts on this thread).

Oh, if you combine 2 posts, then yes, first result will never be shown. I was actually having only first post in mind.

When I want to do a search against a specific country then I get results for that country.
However if I do a search for All. I get no results found?

So in that case (‘All’) what does your SQL statement end up as?