Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2002
    Location
    UK
    Posts
    838

    Select form in PHP/MYSQL

    Hello all

    quick question

    just doing a form which conisists of a drop down menu..of Cities in UK

    what i basically wanna do is that on the Database there is a field called Cities which displays all the cities...... a user selects a city press submits and it goes to see in the database whether there is any city..in the DB

    here is the snippet of the code of the form


    PHP Code:
    <form name="form1" method="post" action="citysearch.php">
        <
    select name=citysearch size=\"1\" id="citysearch">
          <option value=\"none\" selected>Select One</option>
          <option value=\"Aberdeen\">Aberdeen</option>
          <option value=\"Accrington\">Accrington</option>
                <option value=\"Aylesbury\">Aylesbury</option>
          <option value=\"Banbury\">Banbury</option>
          <option value=\"Bangor\">Bangor</option>
                <option value=\"Worthing\">Worthing</option>
          <option value=\"Wrexham\">Wrexham</option>
          <option value=\"Yeovil\">Yeovil</option>
          <option value=\"York\">York</option>
        </select>
        <input type="
    submit" name="Submit" value="Search">
      </form> 
    The city field in my DB is called: comp_location

    to sum it up...user come on the site..does a drop down search for the city...press submits and its then it check the DB to see if that City exists

    cud anyone help me with this please how wud i do this

    thanks
    bye for now

  2. #2
    Join Date
    May 2002
    Location
    Alkmaar, Netherlands
    Posts
    78
    why dont you populate select box from cities in your database? so they can only search from cities available in your database instead of seeing "city is not in our database" message
    Gokhan Arli
    Web Developer(RubyOnRails/MySQL/.NET)
    www.sylow.net

  3. #3
    Join Date
    Dec 2002
    Location
    UK
    Posts
    838
    oh rite

    do u mean something like a user just types in the City..on a search box as opposed to having a drop down menu.....?

    is that what u mean?

    thanks
    bye for now

  4. #4
    Join Date
    Feb 2002
    Location
    uk
    Posts
    110
    or you can create a dropdown menu with only the cities contained in your db.

  5. #5
    Join Date
    Mar 2003
    Location
    PHP =)
    Posts
    110
    yah
    just use a while statement and echo each option

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •