Search form question ( 4 Views )

no kitty!
  1. Hey guys, I need a little help.

    I'm not just a php newb, I'm php illiterate -- don't know a lick of it. None the less, that hasn't stopped my from attempting some hacks on a new php application I just bought.

    I'm proud that a few even work LOL.

    This is going to be a long explaination for what is, I'm sure, a short fix, but I want to explain fully:

    This is what's throwing me:
    PHP Code:

                        if($search_gender != "")
                        { if (
    $search_looking_for != "" && $search_looking_for != "Any")
                             {
    $sql_where = "p.looking_for='$search_gender' and p.gender='$search_looking_for' "; $nWas = 1;
                             }
                         }
    else if(
    $search_looking_for != "" && $search_looking_for == "Any")
                        {
    $nWas = 0;
                        }
    else
                        {
    $sql_where = "p.looking_for='$search_gender' ";
        
    $nWas = 1;    }

    This is from a dating application.

    When a member fills out a profile, they have to list which gender they're looking for, but the program forces the person to choose only 1 gender in their profile that they're searching for. This becomes = "p.looking_for"

    Then, you're allowed to seach by inputting your gender ($search_gender) and the gender you're currently looking for ($search_looking_for).

    The code is to search the profiles, matching men looking for women with women looking for men. It also allows either gender to search for "any" profile regardless of what the searched profile says they're looking for.

    I'd like the script to not only allow men to search "women" or "any"; and women to search for "men" or "any", I'd like members to be able to choose "Looking for any" in their profile (instead of being forced to select 1 gender as it is now) and then have the search function above match "looking for any" with "men" AND "women".

    The best way I can explain this is to note the difference between 1) a man looking for "any" and 2) "any" looking for a "man".

    I THINK that all I have to do is add one line immediately after the very first "if($search_gender != "")". I also THINK that that line would probably be
    PHP Code:

    if($search_looking_for != "" && p.looking_for == "Any")
                        {
    $nWas = 0;
                        }
    else

    Does that look correct?

    Feel free to ask me any other info you need. Thanks ahead of time for any direction (besides the obvious: learn PHP, LOL).

    Mark

    (king ramazan, Monaco)

  2. PHP Code:

    if($search_looking_for != "" && p.looking_for == "Any")

    All I can say is the the above code is incorrect because 'p.looking_for' belongs in a mysql query as it refers to a field in a table.

    My advice is to break it down. Firstly, forget about php and just find out what query needs to be built to pull out the desired data from the db. Then goto the html side of things and make sure that the user can perform the new query. Finally, turn to the php and make sure that query is built depending on if the user has chosen the new option.

    (Nicat, Finland)

  3. Thanks for the response and direction, Streetlife.
    Quote:

    'p.looking_for' belongs in a mysql query
    So is that what this is
    PHP Code:

    $[font=Courier New][color=black]sql_where = "p.looking_for='$search_gender'[/color][/font]

    in
    PHP Code:

    $sql_where = "p.looking_for='$search_gender' and p.gender='$search_looking_for' "; $nWas = 1;

    ???

    (fatih, Kazakhstan)



Related Topics ... (or search in 1.720.883 topics !)

ahh, 'nother site search/form question! (4)
i developed a search form to search your database. guys may find this helpful. (3)
search form within server-side form tags (10)
which search function to use? (also question about plural and singular noun search) (2)
what search engines should i submit to? (was: search engine question?) (5)
help with a search form... (5)
help with search form (5)
search from a form (7)
help with search form (3)




copyright © 2007-2031 Pfodere.COM ( 4 Pfoyihuee Online )

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
1.7194