title: How to use one text field in html form to search any column in database table
body: <p>I'm trying to find out how to use one text field in my form to search any columns in my database table.</p>
  
  <p>Right now it is just searching in sn column on my database table named stock. 
  I need it to search column name  sn or user or status.</p>
  
  <p>So, if you type  in a serial number and post form it will search my database and bring back results with no problems. But I want to be able to type a user's name or status and search my database that way too. So I was thinking of some how dynamically changing the 
  Input name="" with maybe radio buttons to change the value to Input name="sn" or Input name="user" or Input name="status"  But I'm not sure how to do that.  I've been reading others saying with Javascript or JQuery. I would really appreciate any help. Thanks!</p>
  
  <p>I have my recordset to query only sn column.  I'm sure I would need to change this too, but I'm not sure how.</p>
  
  <p>The Form</p>
  
  <pre><code>&lt;form id="form1" name="form1" method="get" action="search.php"&gt;
  &lt;label&gt;
  &lt;input type="radio" name="RadioGroup1" value="sn" id="RadioGroup1_0" /&gt;
  sn&lt;/label&gt;&lt;br /&gt;
  &lt;label&gt;
  &lt;input type="radio" name="RadioGroup1" value="user" id="RadioGroup1_1" /&gt;
  User&lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;
  &lt;input type="radio" name="RadioGroup1" value="status" id="RadioGroup1_2" /&gt;
  Staus&lt;/label&gt;
  &lt;br /&gt;
  &lt;/p&gt;
  &lt;label for="sn"&gt; Search :&lt;/label&gt;
  &lt;input name="sn" type="text" id="sn" size="25" /&gt;
  &lt;input name="submit" type="submit" value="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The SQL</p>
  
  <pre><code>SELECT *
      FROM stock
      WHERE sn = colname
      ORDER BY `datetime` DES
  </code></pre>
  
  <p>The Php</p>
  
  <pre><code>&lt;?php
  if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "",             $theNotDefinedValue = "") 
  {
  if (PHP_VERSION &lt; 6) {
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
  
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string    ($theValue) : mysql_escape_string($theValue);
  
  switch ($theType) {
  case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
  case "long":
  case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
  case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
  case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
  case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
  }
  return $theValue;
  }
  }
  
  $maxRows_Recordset567 = 10;
  $pageNum_Recordset567 = 0;
  if (isset($_GET['pageNum_Recordset567'])) {
  $pageNum_Recordset567 = $_GET['pageNum_Recordset567'];
  }
  $startRow_Recordset567 = $pageNum_Recordset567 * $maxRows_Recordset567;
  
  $colname_Recordset567 = "-1";
  if (isset($_GET['sn'])) {
  $colname_Recordset567 = $_GET['sn'];
  }
  mysql_select_db($database_stock, $stock);
  $query_Recordset567 = sprintf("SELECT * FROM stock WHERE sn = %s ORDER BY  `datetime`  DESC", GetSQLValueString($colname_Recordset567, "text"));
  $query_limit_Recordset567 = sprintf("%s LIMIT %d, %d", $query_Recordset567,    $startRow_Recordset567, $maxRows_Recordset567);
  $Recordset567 = mysql_query($query_limit_Recordset567, $stock) or die(mysql_error());
  $row_Recordset567 = mysql_fetch_assoc($Recordset567);
  
  if (isset($_GET['totalRows_Recordset567'])) {
  $totalRows_Recordset567 = $_GET['totalRows_Recordset567'];
  } else {
  $all_Recordset567 = mysql_query($query_Recordset567);
  $totalRows_Recordset567 = mysql_num_rows($all_Recordset567);
  }
  $totalPages_Recordset567 = ceil($totalRows_Recordset567/$maxRows_Recordset567)-1;
  ?&gt;
  </code></pre>