tahirk Posted October 15, 2016 Share Posted October 15, 2016 I'm having a tags group from where we can select different number of tags. Currently, these tags are being displayed in order in which they are input. I want these to be displayed in an alphabetical order. Here is the php code for the part (ta_name is what I want this to sort to): <div class="control-group"> <label class="control-label" for="qu_tags[]"><?php echo lang("input_tags"); ?></label> <div class="controls"> <select id="qu_tags" name="qu_tags[]" size="10" multiple="multiple"> <option value="">- Choose Tags</option> <?php foreach ($tags as $ta) { ?> <option value="<?php echo $ta["_taid"]; ?>" <?php echo set_select('qu_tags[]', $ta["_taid"]); ?>><?php echo $ta["ta_name"]; ?></option> <?php } ?> </select> <span class="help-inline error"><?php echo form_error("qu_tags[]"); ?></span> </div> </div> Can you please help me in here to display them in an alphabetical order regardless of the way they are input. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 15, 2016 Share Posted October 15, 2016 It is too late to sort $tags at that point. You need to sort it earlier: either in the database query you used, or with something else. Where is $tags defined and where are the values coming from? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.