1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to do a multiple search filter on a db table??

Discussion in 'MySQL' started by 123GoToAndPlay, Feb 26, 2010.

  1. #1
    hi,

    How would i do a multi search on a db table?

    Let's say i have 6 dropdown menu's and on select the appropiate search value is triggered, but with the earlier select search term.??
     
    123GoToAndPlay, Feb 26, 2010 IP
  2. mahno

    mahno Active Member

    Messages:
    172
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #2
    Are you asking for a SQL query example?
     
    mahno, Feb 26, 2010 IP
  3. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry yes,

    well actual both. I am going to use php to parse the result.

    i really would like to use something like this
    http://www.w3schools.com/PHP/php_ajax_database.asp

    but then wit more dropdown's say
    search lastname
    search age
    search hometown
     
    Last edited: Feb 26, 2010
    123GoToAndPlay, Feb 26, 2010 IP
  4. imvain2

    imvain2 Peon

    Messages:
    218
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    this isn't the mysql or php, but it is the javascript function for auto-generating a querystring for attaching to ajax querystring for the db call.

    
    <script>
    function generate_query(){
    	frm=document.forms["selform"];
    	qry="?runquery=1";
    	for(z=0;z<frm.elements.length;z++){
    		if(frm.elements[z].type=="select-one" && frm.elements[z].options.selectedIndex>0){
    			qry += "&" + frm.elements[z].name + "=" + frm.elements[z].options[frm.elements[z].options.selectedIndex].value;
    		}
    	}
    	alert(qry);
    }
    </script>
    
    <form name="selform">
    <select name="term_lastname" onchange="generate_query()">
    <option value="">select last name</option>
    .........
    </select>
    
    <select name="term_age" onchange="generate_query()">
    <option value="">select age</option>
    <option value="a">s</option>
    .........
    </select>
    
    <select name="term_hometown" onchange="generate_query()">
    <option value="">select home town</option>
    <option value="xxx">aaa</option>
    .........
    </select>
    </form>
    
    HTML:
     
    imvain2, Feb 28, 2010 IP
  5. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    @imvain,

    really appreciate the suggestion. I am going to test .

    regards
     
    123GoToAndPlay, Mar 4, 2010 IP
  6. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    @imvain, your suggestion help me out a lot but i am not there quit yet

    Do yo know of a solution for the following: I have a result page loaded with jquery/ajax in a div, when i clicked the details of one of the results i load the details in the div. But now when you hit the back button it doesn't go to the previous results??

    kind regards
     
    123GoToAndPlay, Mar 10, 2010 IP
  7. imvain2

    imvain2 Peon

    Messages:
    218
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'm not sure how to fix that, but it does seem to a common problem. I searched google for ajax back button and there are many results.
     
    imvain2, Mar 10, 2010 IP
  8. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    @imvain2, yep i searched google too but still haven't found a good solution :(
     
    123GoToAndPlay, Mar 12, 2010 IP