title: PHP MySQL search & show row by html <input>
body: <p>I have an HTML form like:</p>
  
  <pre><code>&lt;form  action = "get-row.php"  method = "post" &gt;                  
  &lt;input type = "text"  name = "mess_username" /&gt;
  &lt;input type = "submit" name = "submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And my "get-row.php" is like : </p>
  
  <pre><code>$button = $_POST ['submit'];
  $search = $_POST ['mess_username'];
  
  if (!$button) {
      echo "you didn't submit a keyword";
  }
  else {
      if (strlen($search) &lt;= 1) {
          echo "Search term too short";
      }
      else {
          echo "You searched for &lt;b&gt; $search &lt;/b&gt; &lt;hr size='1' &gt;";
      }
  }
  </code></pre>
  
  <p>I am now successfully getting the value I have searched for. My next approach is to search the $search from my Database. I am trying like:</p>
  
  <pre><code>mysql_connect("server", "user", "pass");
  mysql_select_db("my_db");
  </code></pre>
  
  <p>My Final "ok" Code after currection :</p>
  
  <pre><code>$sql = " SELECT * FROM messbd WHERE mess_username= '$search' ";
  $run = mysql_query($sql);
  
  $foundnum = mysql_num_rows($run);
  
  if ($foundnum == 0) {
      echo "Sorry, there are no matching result for &lt;b&gt; $search &lt;/b&gt;";
  }
  else {
      echo "$foundnum results found !&lt;p&gt;";
  
      while ($runrows = mysql_fetch_assoc($run)) {
          $mess_username = $runrows ['mess_username'];
          $mess_email = $runrows ['mess_email'];
          $android_app = $runrows ['android_app'];
  
          echo " $mess_username  &lt;br&gt; $mess_email &lt;br&gt; $android_app ";
      }
  }
  </code></pre>
  
  <p>The problem is, I am getting the message that, "There are no matching results!" So what will be the correction there?</p>
  
  <p>The problem is solved now &amp; The code is updated above. Thanks.</p>