batch search

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
HI,
i would like to batch search the following mysql data (more than 100k database) by text area,not text field.
in the text area if i input
Code:
26055
15397
15396
15399
15406
15405
26063
15402

it should be able to search "code" column and retrieve only the above data.
how do i do it? any lead it will be appreciable. now i only can search by text filed , one input only.
thanks.


Sample Data.
Code:
Code          int code     description

26055	107078	Write Minds
15397	G88022	Upper Case Plain Wood Letters
15396	G88034	Lower Case Plain Wood Letters
15399	MT01484	Alphabet Fans
15406	PAT13373	Alphabet Workbook
15405	PAT13502	Look Write Hear Charts And Cards Set
26063	ZA595208	Wooden Letters Special Offer
15402	E43449	Magnetic Letters Upper Case
15401	G88824	Magnetic Boards Pack Of 6
15403	H07570	Magnetic Letters Lower Case
15391	J70145	Alphabet Teaching Tubs
13651	PAT13651	Magnetic Promotion
26064	101061	Search And Find Alphabet Bags
15393	G24652	Alphabet Bean Bags
26065	J68988	Squidgy Sparkling Letters
15394	PAT13466	My First Writing Mat Groupwork Set
15395	PAT14030	My First Writing Mat Whole Class
26066	102632	Alphabet Exploration Kit
26068	E41545	Alphabet Squares
26067	J70178	Letter Vests
19389	100685	Theme Mats Square
19390	100686	Theme Mats Rect.
19387	100687	Textured Mats Square
19388	100688	Textured Mats Rect.
19366	100761	Creation Station Tray Rect.
19365	100763	Creation Station Tray Squar
26731	104596	Alphabet Ducks
19391	G16953	Play Sand 12Kg
19392	G89592	Play Sand 25Kg
 
Here is my code so far. i use dreamweaver. but i just dont' know what to do with text area.. thanks for any help

Code:
<?php virtual('/ams/Connections/amscon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$searchstring_Recordset1 = "-1";
if (isset($_GET['searchstring'])) {
  $searchstring_Recordset1 = $_GET['searchstring'];
}
mysql_select_db($database_amscon, $amscon);

$query_Recordset1 = sprintf("SELECT * FROM publisher WHERE pubs_sku = %s", GetSQLValueString($searchstring_Recordset1, "text"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $amscon) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Recordset1") == false && 
        stristr($param, "totalRows_Recordset1") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="795" border="0" cellpadding="0" cellspacing="0">
  
  <tr>
    <td width="25" height="49"></td>
    <td width="35"></td>
    <td colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      
      <tr>
        <td width="396" height="29"></td>
        <td width="165"> </td>
      </tr>
      <tr>
        <td height="19"></td>
        <td valign="top"> </td>
      </tr>
      
      
    </table>    </td>
    <td width="1865"> </td>
    <td width="4"></td>
  </tr>
  <tr>
    <td height="80"> </td>
    <td></td>
    <td colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      
      <tr>
        <td width="561" height="80" valign="top"><form id="form2" name="form2" method="get" action="index.php">
          <label>
            <textarea name="searchstring" id="searchstring" cols="45" rows="5"></textarea>
            </label>
          <label>
          <input type="submit" name="search2" id="search2" value="Submit" />
          </label>
        </form>
        </td>
      </tr>
    </table>
    </td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td height="54"> </td>
    <td></td>
    <td width="495"> </td>
    <td width="66"></td>
    <td></td>
    <td></td>
  </tr>
  
  
  <tr>
    <td height="54" colspan="5" valign="top"><table border="1">
      
        <tr>
          <td>pubs_id</td>
          <td>pubs_brand</td>
          <td>pubs_page</td>
          <td>pubs_new</td>
          <td>pubs_inter_code</td>
          <td>pubs_sku</td>
          <td>pubs_des</td>
          <td>pubs_price</td>
          <td>pubs_haz</td>
          <td>pubs_lenght</td>
          <td>pubs_width</td>
          <td>pubs_height</td>
          <td>pubs_weight</td>
          <td>pubs_origin_code</td>
          <td>pubs_origin</td>
        </tr>
        <?php do { ?>
          <tr>
            <td><?php echo $row_Recordset1['pubs_id']; ?></td>
            <td><?php echo $row_Recordset1['pubs_brand']; ?></td>
            <td><?php echo $row_Recordset1['pubs_page']; ?></td>
            <td><?php echo $row_Recordset1['pubs_new']; ?></td>
            <td><?php echo $row_Recordset1['pubs_inter_code']; ?></td>
            <td><?php echo $row_Recordset1['pubs_sku']; ?></td>
            <td><?php echo $row_Recordset1['pubs_des']; ?></td>
            <td><?php echo $row_Recordset1['pubs_price']; ?></td>
            <td><?php echo $row_Recordset1['pubs_haz']; ?></td>
            <td><?php echo $row_Recordset1['pubs_lenght']; ?></td>
            <td><?php echo $row_Recordset1['pubs_width']; ?></td>
            <td><?php echo $row_Recordset1['pubs_height']; ?></td>
            <td><?php echo $row_Recordset1['pubs_weight']; ?></td>
            <td><?php echo $row_Recordset1['pubs_origin_code']; ?></td>
            <td><?php echo $row_Recordset1['pubs_origin']; ?></td>
          </tr>
          <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
              </table></td>
    <td> </td>
  </tr>
  
  <tr>
    <td height="70"> </td>
    <td colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      
      <tr>
        <td width="54" height="13"></td>
          <td width="415"></td>
          <td width="61"></td>
        </tr>
      <tr>
        <td height="34"></td>
          <td valign="top"> 
            <table border="0">
              <tr>
                <td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
                  <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>">First</a>
                  <?php } // Show if not first page ?>              </td>
                <td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
                  <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a>
                  <?php } // Show if not first page ?>              </td>
                <td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
                  <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a>
                  <?php } // Show if not last page ?>              </td>
                <td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
                  <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
                  <?php } // Show if not last page ?>              </td>
              </tr>
            </table></td>
          <td></td>
        </tr>
    </table></td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td height="56"> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
 
Back
Top