Code For Search Using Combo Box

Discussion in 'PHP' started by rrn, Mar 15, 2009.

  1. #1
    Hi ,

    I have created a page in my website for searching from database using combo box. thid is the html code i used for creating combo box..

    <form method="get">
    						<select name="year" class="combo-75">
    
                                                                                                                                    <option value="2009">2009</option>
    
    						<option value="2008">2008</option>
                                                                                                                                <option value="2007">2007</option>
    					</select>
    					<input type="submit" name="search" value=" Go " class="button" />
    					</form>
    Code (markup):

    How can i search the value from database using php?
    am not sure about the code...pls help...

    Thank u....
     
    rrn, Mar 15, 2009 IP
  2. rrn

    rrn Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is there no one out there to help me in this??

    pls giv a solution...
     
    rrn, Mar 15, 2009 IP
  3. yoes_san

    yoes_san Peon

    Messages:
    443
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yoes_san, Mar 15, 2009 IP
  4. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm not sure what part you are having trouble with. It should be very simple.

    
    $value = intval($_REQUEST['value']);
    $sql = "select * from table where value = {$value}";
    Code (markup):
     
    SmallPotatoes, Mar 15, 2009 IP
  5. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You did the html part, and it still the php part.
    You will need to create a new other file, that will read the combo box value, (with $searchfor = $_POST['nameofcombo']) and search it in the database. But you need to know how to connect to a database.

    Your database is it mysql ?
     
    Ilyes, Mar 15, 2009 IP