⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ps_product_category.inc

📁 php做的网上商店系统。简单易懂
💻 INC
📖 第 1 页 / 共 2 页
字号:
      echo $db->f("category_name") . "</A>:";      echo "&nbsp;&nbsp;" . $db->f("category_description");      echo "</TD><TD CLASS=$class ALIGN=right><A HREF=";      $sess->purl(SECUREURL . "?page=product/product_list&category_id=" . $db->f("category_child_id"));      echo ">List Products</A>\n</TD></TR></TABLE>\n";      $this->traverse_tree_down($class, $db->f("category_child_id"), $level);    }      }    /**************************************************************************  ** name: traverse_tree_up()  ** created by:  ** description: It goes through the category table and establishes  **              the category tree based on the parent-child relationships  **              defnied in the category_xref table.  **              This is VERY recursive...  ** parameters:  ** returns:  ***************************************************************************/  function traverse_tree_up($category_id, $level=0) {    global $ps_vendor_id;    $db = new ps_DB;        $level++;    $q = "SELECT * from category, category_xref ";    $q .= "WHERE category_xref.category_child_id=' ";    $q .= "$category_id' AND ";    $q .= "category.category_id=category_xref.category_parent_id ";    $q .= "AND category.vendor_id = $ps_vendor_id ";    $db->query($q);    while ($db->next_record()) {      if ($level == 1) {	echo "<OPTION SELECTED VALUE=" . $db->f("category_child_id");      }      else {	echo "<OPTION VALUE=" . $db->f("category_child_id");      }      echo ">" . $db->f("category_name") . "</OPTION>";      $this->traverse_tree_up($db->f("category_parent_id"), $level);    }      }  /***************************************************************************  ** name: list_category()  ** created by: pablo  ** description: list all categories and has the category with the given  **              product_id preselected.  ** parameters:  ** returns:  ***************************************************************************/  function list_category($product_id="",$category_id="") {    $db = new ps_DB;    $name = "category_id";    echo "<SELECT NAME=$name>\n";    if ($product_id and !$category_id) {      $q = "SELECT * from product_category_xref WHERE product_id='$product_id'";      $db->query($q);      $db->next_record();      if (!$db->f("category_id")) {        echo "<OPTION VALUE=\"0\">Please Select</OPTION>\n";      }      $this->list_tree($db->f("category_id"));    }     elseif ($category_id) {      $this->list_tree($category_id);    }     else {      echo "<OPTION VALUE=\"0\">Please Select</OPTION>\n";      $this->list_tree();    }        echo "</SELECT>\n";        return True;  }   /***************************************************************************  ** name: list_parents()  ** created by:  ** description:  ** parameters:  ** returns:  ***************************************************************************/  function list_parents($category_id) {    $db = new ps_DB;    echo "<SELECT NAME=$name>\n";    echo "<OPTION VALUE=\"0\">Please Select</OPTION>\n";    $this->traverse_tree_up($category_id);    echo "</SELECT>\n";      }    /**************************************************************************  ** name: print_child_list()  ** created by: pablo  ** description: creates a bulleted of the childen of this category if they   **              exist  ** parameters: category_id  ** returns:  ***************************************************************************/  function print_child_list($category_id) {    global $sess,$ps_vendor_id;    global $modulename;    $db = new ps_DB;    $q = "SELECT * FROM category,category_xref ";    $q .= "WHERE category_xref.category_parent_id='$category_id' ";    $q .= "AND category.category_id=category_xref.category_child_id ";    $q .= "AND category.vendor_id='$ps_vendor_id' ";    $q .= "AND category.category_publish='Y'";    $db->query($q);    while($db->next_record()) {      echo "&nbsp;&nbsp;&nbsp;-<A HREF=";      $sess->purl(SECUREURL . "?page=shop/browse&category_id=" .                                 $db->f("category_child_id"));      echo ">";      $db->p("category_name");      echo "</A><BR>";          }  }  /**************************************************************************  ** name: list_all()  ** created by:  ** description:  ** parameters:  ** returns:  ***************************************************************************/  function list_all($name, $category_id) {    $db = new ps_DB;    $q  = "SELECT * from category_xref ";    $q .= "WHERE category_child_id='$category_id'";    $db->query($q);    $db->next_record();    $category_id=$db->f("category_parent_id");    echo "<SELECT NAME=$name>\n";    echo "<OPTION VALUE=\"0\">Default-Top Level</OPTION>\n";    $this->list_tree($category_id);    echo "</SELECT>\n";  }    /**************************************************************************  ** name: list_tree()  ** created by:  ** description: Creates OPTIONS fields for a select  ** parameters:  ** returns:  ***************************************************************************/  function list_tree($category_id="", $cid=0, $level=0) {    global $ps_vendor_id;    $db = new ps_DB;        $level++;    $q = "SELECT * from category,category_xref ";    $q .= "WHERE category_xref.category_parent_id='";    $q .= $cid . "' AND ";    $q .= "category.category_id=category_xref.category_child_id ";    $q .= "AND category.vendor_id = $ps_vendor_id ";    $db->query($q);    while ($db->next_record()) {      if ($db->f("category_child_id") != $cid) {	if ($db->f("category_child_id") == $category_id) {	  echo "<OPTION SELECTED VALUE=" . $db->f("category_child_id") . ">\n";	}	else {	  echo "<OPTION VALUE=" . $db->f("category_child_id") . ">\n";	}      }      else {          echo "<OPTION VALUE=" . $db->f("category_child_id") . ">\n";      }      for ($i=0;$i<$level;$i++) {        echo "&#151";      }      echo "|$level|";      echo "&nbsp;" . $db->f("category_name") . "</OPTION>";      $this->list_tree($category_id, $db->f("category_child_id"), $level);    }      }   /**************************************************************************  ** name: get_name()  ** created by: jep  ** description: Returns the category name.  ** parameters:  ** returns:  ***************************************************************************/  function get_name($product_id) {    $db = new ps_DB;    $q = "SELECT category_name FROM category,product_category_xref ";    $q .= "WHERE product_id='$product_id' ";    $q .= "AND category.category_id = product_category_xref.category_id ";    $db->query($q);    $db->next_record();    return $db->f("category_name");  }/* Creates navigation list of categgories*/  function navigation_list($category_id) {    global $sess;    $db = new ps_DB;    $dbt = new ps_DB;    static $i=0;    $q = "SELECT * from category, category_xref WHERE ";    $q .= "category_xref.category_child_id='$category_id' ";    $q .= "AND category.category_id='$category_id'";    $db->query($q);    $db->next_record();    if ($db->f("category_parent_id")) {      $link .= "<A HREF=";      $link .= $sess->url(URL . 			  "?page=shop/browse&category_id=$category_id");      $link .= ">";      $link .= $db->f("category_name");      $link .= "</A>";      $category_list[$i++] = ":" . $link;      $this->navigation_list($db->f("category_parent_id"));    }    else {      $link = "<A HREF=";      $link .= $sess->url(URL . 			  "?page=shop/browse&category_id=$category_id");      $link .= ">";      $link .= $db->f("category_name");      $link .= "</A>";      $category_list[$i++] = $link;          }    while (list($key, $value) = each($category_list)) {        echo "$value";    }    return True;   }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -