我在mySQL有一份学院和大学的名单。列表在下拉菜单中从a中填充。我想把选项“没有学校”放在第一位,但我不知道如何做到这一点。
我们正在使用Smarty,所以看起来我需要对tpl文件做些什么。这是我想要编辑的代码。
<div class="question inner">Area of Study</div>
<div class="imp">*</div>
<div class="inp ka3">
<select id="area_studied">
<option value="na"></option>
{foreach from=$area_studied_options item=entry name=foo}
{if $smarty.request.area_studied eq $entry}
<option value="{$entry.user_option_id}" selected>{$entry.value}</option>
{else}
<option value="{$entry.user_option_id}">{$entry.value}</option>
{/if}
{/foreach}
</select>
<span class="add" onclick="addOption('area_studied_location','area_studied')"> </span>
</div>
<div class="clearfix"></div>
<div id="area_studied_location" class="autopop">
{foreach from=$smarty.request.area_studied item=entry name=foo}
<div><input type="checkbox" name="area_studied[]" value="{$entry}" checked>
{foreach from=$area_studied_options item=option name=bar}
{if $entry eq $option.user_option_id}{$option.value}{/if}
{/foreach}
</div>
{/foreach}
</div>
<!-- end: area_studied -->有人能告诉我,我需要做些什么才能把“没有学校”的选项(已经在mysql中)添加到列表的首位?
发布于 2013-12-29 20:48:08
你说‘不上学’选项已经在你的MySQL中了,你只想把它作为第一行返回。然后您可以稍微更改一下MySQL查询:(我猜是列名):
ORDER BY name ASC至
ORDER BY name='no school' ASC, name ASC这将首先返回“没有学校”。
https://stackoverflow.com/questions/20829771
复制相似问题