0

我有一个这样的查询:

  $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>

在此处输入图像描述

我想给你看重复的。有没有办法只打印一次?

4

2 回答 2

0
$mp = NCore::db()->query("SELECT TOWN, NAME FROM CINEMA WHERE CITY_ID = ".$_POST['town']." GROUP BY TOWN, NAME");
于 2012-04-08T06:22:52.897 回答
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");
于 2012-04-08T06:50:14.330 回答