比如这个表
表名:table1:
id name mark
1 aa 1
2 bb 1
3 aa 1
4 cc 2
<?php
$sqlk = PagingSql("table1"," where mark =1 order by name ASC, id desc",$page,150,"aaa.php?");
$rsk = mysql_query($sqlk[sql]);
while($rstk = mysql_fetch_array($rsk))
{?>
<a href="aa-<?php echo $rstk[id] ?>.php"><?php echo $rstk[name] ?></a>
<?php } ?>
这样输出的是 aa bb aa;
我需要的是去掉重复的aa;只输出aa bb:
解决了:
<?php
$query = "select distinct name from table1 where mark =1 order by name ASC";
mysql_query("SET name GBK");
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){ ?>
<a href="aa-<?php echo $row[id];?>.php><?php echo $row[gj];?></a>
<?php } ?>