Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 拆分分类法柱基类别、品牌和设计师_Php_Mysql_Arrays - Fatal编程技术网

Php 拆分分类法柱基类别、品牌和设计师

Php 拆分分类法柱基类别、品牌和设计师,php,mysql,arrays,Php,Mysql,Arrays,我想获取术语_id(基于category、brand和designer中的拆分分类列) 这是表格结构 表:wp_术语_分类法 我需要这样的输出 Array ( [0] => 249 [1] => 250 [2] => 251 [3] => 252 [4] => 250 [5] => 251 [6] => 254 ) 我不确定我是否正确,因为我不理解术语分类法\u id的必要性,

我想获取术语_id(基于category、brand和designer中的拆分分类列)

这是表格结构

表:wp_术语_分类法

我需要这样的输出

    Array (
    [0] => 249
    [1] => 250
    [2] => 251
    [3] => 252
    [4] => 250
    [5] => 251
    [6] => 254
    ) 

我不确定我是否正确,因为我不理解术语分类法\u id的必要性,但如果它能帮助您:

<?php
while($row2 = mysql_fetch_array($result)){

      $object_id = $row2['object_id'];

      $sql ="select term.term_taxonomy_id,wp.term_id from wp_term_relationships as term  inner join wp_term_taxonomy as wp ON term.term_taxonomy_id=wp.term_taxonomy_id where object_id = $object_id";

      $results = mysql_query($sql);

      $i=0;
     while($row3 = mysql_fetch_array($results)){
         $term_taxonomy_id1[$i] = $row3['term_taxonomy_id'];

         $res_term_id[$i] = $row3['term_id'];

       }
}
这不是最好的,您仍然可以使用联接过程来提高性能,但它应该可以工作

       Array
    (
    [category] => Array
      (
      [0] => 177
      [1] => 179
      )
    [brand] => Array
      (
      [0] => 176
      )
    [designer] => Array
      (
      [0] => 175
      [1] => 180
      )
    ) 
<?php
while($row2 = mysql_fetch_array($result)){

      $object_id = $row2['object_id'];

      $sql ="select term.term_taxonomy_id,wp.term_id from wp_term_relationships as term  inner join wp_term_taxonomy as wp ON term.term_taxonomy_id=wp.term_taxonomy_id where object_id = $object_id";

      $results = mysql_query($sql);

      $i=0;
     while($row3 = mysql_fetch_array($results)){
         $term_taxonomy_id1[$i] = $row3['term_taxonomy_id'];

         $res_term_id[$i] = $row3['term_id'];

       }
}
$data=array();
while($row3=mysql_fetch_assoc($result)){
  $taxonomy=$row3['taxonomy'];
  $sql2="select term_id from wp_term_relationships where taxonomy=$taxonomy";
  $res=mysql_query($sql2);
  while($row4=mysql_fetch_assoc($res)){
    $tab[]=$row4['term_id'];
  }
  $data[$taxonomy]=$tab;
}