I've got a database of states, cities, and listings. Within each city, I have multiple listings. For example:
FL => Miami => 10 listings
I am trying to populate a State drop-down menu with each State, however, my SQL query is pulling back ALL rows and creating multiple entries of States. In the example above, FL is appearing 10 times in the drop-down, because there are 10 records for it in the database.
But this doesn't look correct in the State drop-down menu. There should only be 1 FL. Hope someone can help!
Here is my query:
$squery = mysql_query("SELECT * FROM wp_postmeta WHERE wp_postmeta.post_id AND wp_postmeta.meta_key = 'state'");
Here is my output:
<?php while($state_name = mysql_fetch_array($squery)) { ?>
<option value="<?php if(isset( $state_name['meta_value'] )) { echo state_name['meta_value']; } ?>">
<?php if(isset( $state_name['meta_value'] )) { echo $state_name['meta_value']; }?>
</option><?php } ?>