我有这样的查询:
$mp = NCore::db()->query("SELECT DISTINCT TOWN,NAME FROM CINEMA WHERE CITY_ID = ".$_POST['town']."");
我想要的是像这样的东西
格林维尔 ..... ..... ..... 富兰克林 ....... .......
我有下面的代码,但它写了所有的城镇名称。我想要的是我想只写一次城镇名称。有没有办法做到这一点?
<h1>Son eklenen sinema salonları</h1>
<form action="#" method="post">
<table border ="1">
{foreach value=mp from=$mpbycity}
<tr>
<td>
{$mp.TOWN}
</td>
</tr>
<tr>
<td>
{$mp.NAME}
</td>
</tr>
{/foreach}
</table>
</form>
我想告诉你重复的内容。有没有办法只打印一次?
答案 0 :(得分:0)
$mp = NCore::db()->query("SELECT TOWN, NAME FROM CINEMA WHERE CITY_ID = ".$_POST['town']." GROUP BY TOWN, NAME");
答案 1 :(得分:0)
$mp = NCore::db()->query("SELECT TOWN,NAME FROM CINEMA WHERE CITY_ID = ".$_POST['town']." GROUP BY TOWN");
只有你想要独特的TOWN
如果是NAME和TOWN
$mp = NCore::db()->query("SELECT TOWN,NAME FROM CINEMA WHERE CITY_ID = ".$_POST['town']." GROUP BY TOWN,NAME");