Multiple Query Options On One PHP Page

Discussion in 'Databases' started by timallard, Feb 25, 2009.

  1. #1
    Hello,

    Im making a DB search tool...where you can choose which way to search with a dropdown,...e.g by keyword, by name etc.

    Im using this query code.

    if(isset($_GET['Town']) && !empty($_GET['Town']) && is_numeric($_GET['Town']))
    $Town = trim($_GET['Town']);
    $query= "SELECT * FROM curiosities WHERE Town='".mysql_real_escape_string($Town)."'";
    $result = mysql_query($query) or die(mysql_error());
    $num_rows = mysql_num_rows($result);

    im also displaying that result with <?php echo $row1['FirstName']; ?>. inside a while loop <?php while($row1 = mysql_fetch_array($result)){ ?>

    my questions is this:
    Ok so this works for searching by Town,...but i want to be able to add another way to search, eg. by first name,..when i duplicate it and change the variables it no longer works..i need them to be able to choose what way they would like to search from.

    I also will need the new result to display in $row1


    I appreciate anything. thank you, -Tim
     
    timallard, Feb 25, 2009 IP
  2. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #2
    would this be en else statement to GET the dropdown var?
     
    timallard, Feb 25, 2009 IP
  3. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #3
    This has been fixed, i place dit in an if else statement looking for a variable in my query string. Depending on the variable it chose the correct query.

    ROCK. ON.
     
    timallard, Feb 25, 2009 IP