我为一个类型做了一个计数器,一切正常,但有一个问题。
有两种不同的类型。我只想要1种类型的数量而不是两者。 类型1 =电影 type 2 = tvshow
$genre_list = array('Action','Adult','Adventure','Animation','Biography','Bollywood','Comedy','Crime','Documentary','Drama','Family','Fantasy','History','Horror','Musical','Mystery','Reality-TV','Sci-Fi','Sport','Thriller','War','Western');
$query_parts = array();
foreach ($genre_list as $genre) {
$query_parts[] = "'%".mysql_real_escape_string($genre)."%'";
}
$string = implode(' OR genre LIKE ', $query_parts);
$tank = mysql_query("SELECT genre FROM `topmovies`.`movies` WHERE type='tvshow' AND genre LIKE {$string} GROUP BY name");
while( $fetch = mysql_fetch_array( $tank ) ){
$count = explode(', ', $fetch['genre']);
foreach( $count as $w)
if( in_array($w, $genre_list) )
$query_parts[$w]++;
}
如你所见,我想计算所有类型为'tvshow'的游戏类型,但问题是,它也会计算“电影”类型的类型!
我真的没有弄错..
答案 0 :(得分:0)
变化
AND genre LIKE {$string}
至
AND (genre LIKE {$string})
当前查询形式如:
(type ='tvshow'AND genre LIKE“a”)或类型如“b”** ....