SELECT FLOOR RAND

时间:2015-11-27 13:07:44

标签: php mysql

我有一个问题:

$offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` `".$slug."_movie`");
$offset_row = mysql_fetch_object( $offset_result );
$offset = $offset_row->offset;
$result = mysql_query( " SELECT * FROM `".$slug."_movie` LIMIT $offset, 10 " ); 

如何添加条件:STATUS = 1?

仅计算已发布的电影..

现在它全部:/

有人会举个例子吗?

1 个答案:

答案 0 :(得分:0)

像这样:

$result = mysql_query( " SELECT * FROM `".$slug."_movie` WHERE STATUS=1 LIMIT $offset, 10 " );