Linking, Indexing Question

Discussion in 'PHP' started by nile1483, Jul 4, 2008.

  1. #1
    hello friend

    i have one question for navigate my website

    i have following field in my database table

    1. Name

    2. Category

    3. City

    i want to display data in list.php

    user can go to list.php page by

    1. clicking on list of category url is domain.com/list.php?category="category_name"

    2. Clicking on City list of city url is domain.com/list.php?city="city_name"

    i do the above to matter successfully

    now i add one search box in list.php

    form is
    1. <select name="category"><option value="category list"></option></select>

    2. <select name="city"><option value="city list"></option></select>
    3. <input type ="submit">

    question is i want url like if user select both category and city url must be domain.com/list.php?category="category_name"&city="city_name"

    if user select only category url must be domain.com/list.php?category="category_name"

    and if user select only city url must be domain.com/list.php?city="city_name"

    Reputation sure for good answer
    thanks you
     
    nile1483, Jul 4, 2008 IP
  2. anwaraa

    anwaraa Active Member

    Messages:
    167
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    Digital Goods:
    2
    #2
    Hi

    Make your form action to list.php using get method. If only 1 select is choosen, the other will be like:
    domain.com/list.php?category=&city="city_name" . ie. There is nothing shown if not selected.

    At the top of your list.php, you must put this:

    if(isset($_GET['category']))
    {
    $category=$_GET['category'];
    }

    if(isset($_GET['city']))
    {
    $city=$_GET['city'];
    }
     
    anwaraa, Jul 6, 2008 IP
    nile1483 likes this.
  3. nile1483

    nile1483 Active Member

    Messages:
    345
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Hi anwara

    I use Get Method and Its Done,

    Thanks for your Answer,

    i add reputation

    Regards
    Nilesh valanki


     
    nile1483, Jul 7, 2008 IP
  4. anwaraa

    anwaraa Active Member

    Messages:
    167
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    Digital Goods:
    2
    #4
    Thank you. Glad to help
     
    anwaraa, Jul 11, 2008 IP