PHP过滤记录集

时间:2015-02-08 02:39:16

标签: php

使用位于此处的在线广告资源系统... http://wheelworldinc.com/catalog/viewsizesearch.php

有2个数量列...一个用于波特兰,一个用于加利福尼亚。

我想列出仅限波特兰最低到最低数量的结果。因此,加利福尼亚州的数量对于显示顺序并不重要。

这是来自页面的代码......



<?php require_once('../Connections/wheel.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;
}
}

$colname_Recordset1 = "-1";
if (isset($_POST['size'])) {
  $colname_Recordset1 = $_POST['size'];
}
$colname2_Recordset1 = "-1";
if (isset($_POST['inholes'])) {
  $colname2_Recordset1 = $_POST['inholes'] ."x" . $_POST['indiameter'];
}
mysql_select_db($database_wheel, $wheel);
 
$query_Recordset1 = sprintf("SELECT * FROM `catalog` WHERE `size` LIKE %s AND `boltpattern` LIKE %s AND (`catalog`.Utah NOT LIKE 0 OR `catalog`.portland NOT LIKE 0 OR `catalog`.cal NOT LIKE 0) ORDER BY partnumber", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"),GetSQLValueString("%" . $colname2_Recordset1 . "%", "text"));
$Recordset1 = mysql_query($query_Recordset1, $wheel) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Wheel World Database Admin Area</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="admin/mm_entertainment.css" type="text/css" />
<style type="text/css">

<!--
a {
	font-family: Georgia, Times New Roman, Times, serif;
	color: #99CCE6;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
	color: #000099;
}
a:active {
	text-decoration: none;
}
.style2 {font-size: large}
.style3 {font-size: x-large}
.style4 {font-size: 18px}
-->
</style></head>
<body bgcolor="#14285f">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="02021e">
    <td colspan="2" rowspan="2" nowrap="nowrap" bgcolor="#000000"><img src="images/orange-banner.jpg" alt="Header image" width="720" height="156" border="0" /></td>
    <td height="58" colspan="2" valign="bottom" nowrap="nowrap" bgcolor="#000000" id="logo">Online Inventory </td>
    <td width="68" bgcolor="#000000">&nbsp;</td>
  </tr>
  <tr bgcolor="02021E">
    <td height="57" colspan="2" valign="top" nowrap="nowrap" bgcolor="#000000" id="tagline"><br />	  </td>
	<td width="68" bgcolor="#000000">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#cc3300"><img src="admin/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="5"><img src="admin/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="5" bgcolor="#cc3300"><img src="admin/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

  <tr>
    <td colspan="5" id="dateformat">&nbsp;<br />
	&nbsp; &nbsp; <a href="index.php">Search</a><br />
	&nbsp; &nbsp;<br />	</td>
  </tr>
  <tr>
    <td width="192" align="left" valign="top"><div align="center" class="style3"></div>
    <td colspan="2" valign="top"><br />
	<table width="683" border="0" align="center" cellpadding="2" cellspacing="0">
        <tr>
          <td class="subHeader">Welcome to the Wheel World Inc Online Inventory</td>
        </tr>
        <tr>
          <td align="left" valign="top" class="bodyText">
            <form id="emptyquantity" name="emptyquantity" method="post" action="viewsizesearchempty.php">
              <label>
              <div align="center">
                <input type="hidden" name="size" value="<?php echo $_POST['size']; ?>" id="size" /><input name="inholes" type="hidden" value="<?php echo $_POST['inholes']; ?>" /><input name="indiameter" type="hidden" value="<?php echo $_POST['indiameter']; ?>" />
                Click here to view Part Numbers which may be available for special   order:
                <input type="submit" name="submit" id="submit" value="  View Zero Quantities  " />
              </div>
              </label>
                        </form>
            <p align="center" class="style4">&nbsp;</p>
            <?php if ($totalRows_Recordset1 == 0) { // Show if recordset empty ?>
              <p class="style3">No Results for this Size!</p>
              <?php } // Show if recordset empty ?>
<?php if ($totalRows_Recordset1 > 0) { // Show if recordset not empty ?>
                  <span class="style2">Results for Search for Wheel Size <?php echo $_POST['size']; ?> BoltPattern <?php echo $_POST['inholes']; ?>x<?php echo $_POST['indiameter']; ?></span> <br />
                  <br />
              <table width="725" border="1" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
        <tr>
          <td width="106" align="center">Photo</td>
          <td width="185" align="center">partnumber</td>
          <td width="172" align="center">Description</td>
          <td width="234" colspan="3" align="center" >Warehouses/Quantity</td>
        </tr>
        <?php do { ?>
          <tr>
            <td rowspan="2" align="center"><a href="viewitem.php?id=<?php echo ($row_Recordset1['id'].'&size='.$_POST['size'].'&bolt='.$_POST['inholes'].'&dia='.$_POST['indiameter']);?>"><img  border="0" width="100"src="admin/wheelthumb/tn_<?php echo $row_Recordset1['image']; ?>" vspace="3" /></a></td>
            <td rowspan="2" align="center"><a href="viewitem.php?id=<?php echo $row_Recordset1['id']; ?>"><?php echo $row_Recordset1['partnumber']; ?></a></td>
            <td rowspan="2" align="center"><?php echo $row_Recordset1['description']; ?></td>
            
            <td align="center" valign="middle">Portland</td>
            <td align="center" valign="middle">California</td>
          </tr>
          <tr>
            
            <td align="center"><?php echo $row_Recordset1['portland']; ?></td>
            <td align="center"><?php echo $row_Recordset1['cal']; ?></td>
          </tr>
          <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
            </table>
                  <?php } // Show if recordset not empty ?><br /></td>
		</tr>
      </table></td>
    <td width="125">&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
  <tr>
    <td width="192">&nbsp;</td>
    <td width="564">&nbsp;</td>
    <td width="325">&nbsp;</td>
    <td width="125">&nbsp;</td>
	<td width="68">&nbsp;</td>
  </tr>
</table>
<br />
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
&#13;
&#13;
&#13;

任何帮助肯定会受到赞赏!

0 个答案:

没有答案