Burak
Burak

Reputation: 245

Make a Dropdown list sort by number

I made a dropdown menu and tried to list it. But the list in the db doesn't start with "H01" so my dropdown starts with "H40"

How can I replace the code:

like 'H%'

Code and Frontend

Upvotes: 0

Views: 64

Answers (2)

Niranjan K.
Niranjan K.

Reputation: 21

You need to add order_by to your select query.

For example

<?php
  $query = "SELECT * FROM `status` ORDER BY `status`.`status` ASC";
?>

Here status field has values like H01, H02, H03, ... H10

Upvotes: 0

Prashant mishra
Prashant mishra

Reputation: 68

Please add order by your_column_name ASC in your query.

Upvotes: 1

Related Questions