在php中从下拉列表中删除重复值

mutmk8jj  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(193)

嗨,我正在尝试从下拉列表中删除重复值。但不知怎的我不知道该怎么做。
这是我的密码:

/**
     * Get order ticket details
     */
    public function ticketDetailsAction()
    {
        $orderId = $this->getRequest()->getParam('orderId', 0);
        $contactId = $this->getRequest()->getParam('contactId', 0);
        $bootstrap = $this->getInvokeArg('bootstrap');
        $ticketService = new Tickets_Service_Ticket($bootstrap->getOptions());
        $userId = $this->getUserInfo()->getId();
        $params = array(
            'depotAndAffiliateIds' => array_keys($this->_affiliatedDepotMastersWithActiveDepot),
            'orderId' => $orderId,
            'contactId' => (int)$contactId,
            'user' => $userId,
        );
        $options = array(
            'language' => BAS_Shared_Model_Ticket::LANGUAGE_DEFAULT,
            'user' => $userId,
            'translate' => $bootstrap->getResource('translate'),
            'config' => $bootstrap->getResource('config'),
        );
        $ticketGridService = new Ticket_Service_Grid($ticketService, $options);
        if (0 < (int)$contactId) {
            $this->view->ticketGridObject =  $ticketGridService->getGrid(Ticket_Service_Grid::GRID_TYPE_ORDERTICKETOVERVIEW, $params);
        }
        if (empty($this->view->ticketGridObject)) {
            $where = array('depot_id in (?)' => array_keys($this->_affiliatedDepotMastersWithActiveDepot));
            $this->view->ticketSources = $ticketService->getTicketSourceList($where);
        }
    }

 /**
 * Get ticket source list
 * 
 * @param array $whereCondition
 * @return array
 */
public function getTicketSourceList($whereCondition = array())
{
    /**@var BAS_Shared_Model_TicketSourceMapper  */
    $ticketSource = $this->getMapper('TicketSource');

    return $ticketSource->findAllByCondition($whereCondition, 'source ASC');
}

 /**
 * @param string|array|Zend_Db_Table_Select|null $where
 * @param string|array|null $order
 * @param int|null $count
 * @param int|null $offset
 * @return array|BAS_Shared_Model_AbstractModel[]
 */
public function findAllByCondition($where = null, $order = null, $count = null, $offset = null)
{
    $rows = $this->getDao()->fetchAll($where, $order, $count, $offset);
    $models = [];

    while(($row = $rows->current()) !== null) {
        $models[] = $this->mapRow($row);
        $rows->next();
    }

    $this->resetMapToModel();

    return $models;
}

以下是我的观点:

<select id="ticketSource">
        <option value="">--<?php echo $this->translate('select') ?>--</option>
        <?php foreach ($this->ticketSources as $ticketSource) : ?>
            <option value="<?php echo $ticketSource->source ;?>"><?php echo $ticketSource->source;?></option>
        <?php endforeach;?>
    </select>

如何在这里添加不同的条件。我已经添加了我的完整控制器功能和其余的功能了。我已经添加了我的视图页代码,这将创建下拉代码。
有人能帮我吗
提前谢谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题