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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.