title: Get Mysql table row data based on form submit values
body: <p>I need to fetch the rows based on form submission values.</p>
  
  <p>Here is my form</p>
  
  <pre><code>&lt;form name="choose" method "post" t" action="search.php"&gt;
      &lt;table&gt;
      &lt;tr&gt;
          &lt;tr&gt;
              &lt;td height="3"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;td width="60"&gt;
              &lt;font1&gt;Prof&lt;/font1&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;select name proffession on&gt;
                  &lt;option value=""&gt;&lt;/option&gt;
                  &lt;option value="doctor"&gt;&lt;font4&gt;Doctor&lt;/font&gt;&lt;/option&gt;
                  &lt;option value="designer"&gt;Designer&lt;/option&gt;
              &lt;/select&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;tr&gt;
              &lt;td height="3"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;td width="60"&gt;
              &lt;font1&gt;Source&lt;/font1&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;select name source&gt;
                  &lt;option value=""&gt;&lt;/option&gt;
                  &lt;option value="x"&gt;&lt;font4&gt;X&lt;/font&gt;&lt;/option&gt;
                  &lt;option value="y"&gt;Y&lt;/option&gt;
                  &lt;option value="z"&gt;Z&lt;/option&gt;
              &lt;/select&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;tr&gt;
              &lt;td height="3"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;td width="60"&gt;
              &lt;font1&gt;Location&lt;/font1&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;select name location on&gt;
                  &lt;option value=""&gt;&lt;/option&gt;
                  &lt;option value="bangalore"&gt;Bangalore&lt;/option&gt;
                  &lt;option value="delhi"&gt;Delhi&lt;/option&gt;
              &lt;/select&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;input name=look type=submit value=submit&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>If there is any empty field submission i need to fetch the rows excluding that column.
  Here is my search.php</p>
  
  <pre><code> &lt;?php
  mysql_connect("localhost","root","");//database connection
  mysql_select_db("alldata");
  $qry = "SELECT * FROM data WHERE location LIKE '" . mysql_escape_string($_POST['location']) . "' And proffession LIKE '" . mysql_escape_string($_POST['proffession']) . "' And source LIKE '" . mysql_escape_string($_POST['source']) . "'";
  
  $res = mysql_query($qry);
  function mysql_fetch_all($res) {
     while($row=mysql_fetch_array($res)) {
         $return[] = $row;
     }
     return $return;
  }
  function create_table($dataArr) {
      echo "&lt;tr&gt;
  "; for($j = 0; $j &lt; count($dataarr); $j++) { echo "&lt;td&gt;".$dataArr[$j]."
  &lt;/td&gt;
  "; } echo "
  &lt;/tr&gt;
  "; } $all = mysql_fetch_all($res); echo "
  &lt;table class='data_table'&gt;
  "; for($i = 0; $i &lt; count($all); $i++) { create_table($all[$i]); } echo "&lt;/table&gt;";
  ?&gt;
  </code></pre>
  
  <p>But this script is not able to get me a solution.
  Please help</p>