Jump to content

Search form question


gaz

Recommended Posts

Hello,

 

I'm using a script that lists properties and allows users to search by given criteria i.e. cost, location and bedrooms etc.

 

I'm attempting to modify my search form for a particular field, changing it from a text field to a dropdown.

 

My table has a row titled, address_city, of course cities are duplicated in the table i.e. there may be 10 for London. I have the following code working but the dropdown displays every instance of the city - in this case 10. So please could someone tell me how to write this so each city is only listed once in my dropdown?

 

<?php
				$sql = "SELECT  * FROM ".$TABLES['properties']." ORDER BY title;";
				$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);

				while ($row = mysql_fetch_assoc($sql_result)) {
					?>
					<option value="<?php echo $row['id'];?>"><?php echo $row['address_city'];?></option>
					<?php
				}
				?>

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/252458-search-form-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.