嗨,我有一个 PHP 分页系统,我想做的是使用 Distinct 仅返回唯一值,发生的情况是页面显示应该有多少页面,但没有给我任何结果。
我的代码在这里
$query = "SELECT DISTINCT ip_address,
COUNT(*) as num
FROM $tableName
WHERE hostname
LIKE 'mail%' AND type='6'";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$stages = 3;
$page = mysql_escape_string($_GET['page']);
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
// Get page data
$query1 = "SELECT DISTINCT ip_address,
hostname
FROM masterip_details
WHERE hostname
LIKE 'mail%' AND type='6'
LIMIT $start, $limit";
$result = mysql_query($query1);