Hay大家帮忙帮忙。
在我的电影页面上,我可以按照4件事来分类电影,但一次只能分1个
ABC
Date Added
Imdb Ratings
Year
但是我试着做的是一次用2个东西对电影进行排序年份和Imdb评级,但它不会工作。
请你检查导致错误的原因
这是公共功能代码
public function getRealMovies($lang=null, $p=null, $l=null, $sortby=null){
$movies = array();
if (($p) && ($l)){
$start = ($p-1)*$l;
$limit = " LIMIT $start,$l";
} else {
$limit = '';
}
if (!$sortby || $sortby=='abc'){
$order = "ORDER BY title ASC";
} elseif ($sortby=='date'){
$order = "ORDER BY date_added DESC";
} elseif ($sortby=='imdb_rating'){
$order = "ORDER BY imdb_rating DESC";
} elseif ($sortby=='year'){
$order = "ORDER BY year DESC";
} elseif ($sortby=='imdb_rating&year'){
$order = "ORDER BY imdb_rating, year DESC";
}
$e = mysql_query("SELECT * FROM movies WHERE id IN (SELECT movie_id FROM movie_embeds) $order $limit") or die(mysql_error());
if (mysql_num_rows($e)>0){
$ids = array();
while($s = mysql_fetch_array($e)){
$movies[$s['id']] = $this->formatMovieData($s, $lang);
$ids[] = $s['id'];
}
if (count($ids)){
$flags = $this->getFlags($ids);
if (count($flags)){
foreach($movies as $movie_id => $val){
if (array_key_exists($movie_id,$flags)){
$movies[$movie_id]['languages'] = $flags[$movie_id];
} else {
$movies[$movie_id]['languages'] = array();
}
}
}
}
}
return $movies;
}
这是Rewrite Roles
RewriteRule ^/?movies/(\d+)$ index.php?menu=movies&p=$1&sortby=abc&lang=en [L]
RewriteRule ^/?movies/abc/(\d+)$ index.php?menu=movies&p=$1&sortby=abc&lang=en [L]
RewriteRule ^/?movies/date/(\d+)$ index.php?menu=movies&p=$1&sortby=date&lang=en [L]
RewriteRule ^/?movies/imdb_rating/(\d+)$ index.php?menu=movies&p=$1&sortby=imdb_rating&lang=en
RewriteRule ^/?movies/year/(\d+)$ index.php?menu=movies&p=$1&sortby=year&lang=en
RewriteRule ^/?movies/date index.php?menu=movies&sortby=date&lang=en
RewriteRule ^/?movies/abc index.php?menu=movies&sortby=abc&lang=en
RewriteRule ^/?movies/imdb_rating index.php?menu=movies&sortby=imdb_rating&lang=en
RewriteRule ^/?movies/year index.php?menu=movies&sortby=year&lang=en
RewriteRule ^/?movies/fav index.php?menu=movies&sortby=imdb_rating&year&lang=en
RewriteRule ^/?movies index.php?menu=movies&lang=en [L]
RewriteRule ^/?requests index.php?menu=requests&lang=en [L]
以下是钮扣
<li{if $sortby eq 'abc'} class="current"{/if}><a href="{$baseurl}/{$routes.movies}/abc">{$lang.sorting_abc}</a></li>
<li{if $sortby eq 'date'} class="current"{/if}><a href="{$baseurl}/{$routes.movies}/date">{$lang.sorting_newest}</a></li>
<li{if $sortby eq 'imdb_rating'} class="current"{/if}><a href="{$baseurl}/{$routes.movies}/imdb_rating">{$lang.sorting_imdb}</a></li>
<li{if $sortby eq 'year'} class="current"{/if}><a href="{$baseurl}/{$routes.movies}/year">{$lang.released}</a></li>
<li{if $sortby eq 'imdb_rating&year'} class="current"{/if}><a href="{$baseurl}/{$routes.movies}/imdb_rating&year">Fav</a></li>
{else}
<li{if $sortby eq 'abc'} class="current"{/if}><a href="{$baseurl}/index.php?menu=movies&sortby=abc">{$lang.sorting_abc}</a></li>
<li{if $sortby eq 'date'} class="current"{/if}><a href="{$baseurl}/index.php?menu=movies&sortby=date">{$lang.sorting_newest}</a></li>
<li{if $sortby eq 'imdb_rating'} class="current"{/if}><a href="{$baseurl}/index.php?menu=movies&sortby=imdb_rating">{$lang.sorting_imdb}</a></li>
<li{if $sortby eq 'year'} class="current"{/if}><a href="{$baseurl}/index.php?menu=movies&sortby=year">{$lang.released}</a></li>
<li{if $sortby eq 'imdb_rating&year'} class="current"{/if}><a href="{$baseurl}/index.php?menu=movies&sortby=imdb_rating&year">Fav</a></li>
任何人都可以帮忙吗
谢谢:)
答案 0 :(得分:2)
您使用的是条件elseif ($sortby=='imdb_rating&year')
,但&year
是GET HTTP请求中的新密钥,换句话说,$sortby
在这种情况下只有'imdb_rating'
值。< / p>
您必须使用其他分隔符,例如:
elseif ($sortby=='imdb_rating_and_year')
并更改重写规则:
RewriteRule ^/?movies/fav index.php?menu=movies&sortby=imdb_rating&year&lang=en
到此:
RewriteRule ^/?movies/fav index.php?menu=movies&sortby=imdb_rating_and_year&lang=en
和模板中的相同更改。