title: Multiple search option in PHP MySQL AJAX
body: <p>I want to put multiple search option in PHP file through AJAX method. With one search (Search by name )option its working fine but when I put another search field ( Like Search by gender) then its search only with gender only. I can't do search for both of them at a same time. 
  This is main index.php file</p>
  
  <pre><code> This is tablepage.php file where ajax method calling + display data
  
  &lt;script charset="UTF-8"&gt;
  
      function pagination(page)
        {
            var search = $("input#fieldSearch").val();
            var record = $("select#pageRecord").val();
            var gender = $("select#fieldSearch1").val(); 
            if (search!=="")
            {
              dataString = 'starting='+page+'&amp;gender='+ gender+'&amp;name='+search+'&amp;perpage='+ record+'&amp;random='+Math.random();
          }
  
           else{
                dataString = 'starting='+page+'&amp;perpage='+record+'&amp;random='+Math.random();
              }
  
          $.ajax({
           url:"tablepage.php",
           data: dataString,
           type:"GET",
           success:function(data)
           {
              $('#divPageData').html(data);
            }
         });
       }
  
          function loadData()
         {
            var dataString;
            var search = $("input#fieldSearch").val();
            var record = $("select#pageRecord").val();
            var gender = $("select#fieldSearch1").val();
          dataString = '&amp;gender=' + gender + 'name='+ search + '&amp;perpage=' + record;
  
  
         $.ajax({
               url: "tablepage.php",
               type: "GET",
               data: dataString,
              success:function(data)
                {
                   $('#divPageData').html(data);
                }
          });
         }
      &lt;/script&gt;
  
  &lt;?php
     error_reporting(E_ALL^E_NOTICE);
     include('pagination_class.php');
     include('connect.php');
  
      if (isset($_GET['name']) and !empty($_GET['name'])){
         $name = $_GET['name'];
          $sql = "select * from fmaf where name like '%$name%'";
  
            }
             if (isset($_GET['gender']) and !empty($_GET['gender'])){
                $gender = $_GET['gender'];
              $sql = "select * from fmaf where gender = '$gender'";
  
             }
            else{
  
          $sql="select * from fmaf left join status ON fmaf.id = status.sid GROUP BY fmaf.id ";
  
          }
  
            if(isset($_GET['starting'])){ //starting page
                   $starting=$_GET['starting'];
                  }else{
                $starting=0;
               }
  
             $recpage=$_GET['perpage'];
  
              $obj = new pagination_class($sql,$starting,$recpage);       
             $result = $obj-&gt;result;
         ?&gt;  
  </code></pre>
  
  <p>this is pagination.js file </p>
  
  <pre><code>$(document).ready(function(){
  
              $('#divLoading').ajaxStart(function(){
              $(this).fadeIn();
              $(this).html("&lt;img src='loading.gif' /&gt; ");
                }).ajaxStop(function(){
                  $(this).fadeOut();
              });
  
  
             loadData();
  
  
            function loadData()
             {
               var dataString;
               var search = $("input#fieldSearch").val();
               var record = $("select#pageRecord").val();
               var gender = $("select#fieldSearch1").val();   
  
  
             dataString = '&amp;gender=' + gender + 'name='+ search + '&amp;perpage=' + record;
  
  
             $.ajax({
                 url: "tablepage.php",
                   type: "GET",
               data: dataString,
                 success:function(data)
                 {
                  $('#divPageData').html(data);
                }
          });
         }
  
            $("form#formSearch").submit(function()
              {
                   loadData();
                 return false;
                });
  
  
                   }); 
  </code></pre>
  
  <p>Rest of pagination.class.php file is working fine.</p>