Reputation: 17
I would like to display only the first characters in the drop down list.
For example, I have names like Adam,Harry,James in mysql table. I've created a dropdown list showing the names Adam,Harry etc. But, I want to display only their first characters like A,H,J etc. in the drop down list. Is there any way to do it?
Upvotes: 1
Views: 327
Reputation: 2059
Try something like this. I hope this will help.
<option value='" . $row['name'] ."'>" . substr($row['name'], 0, 1) ."</option>
Upvotes: 0
Reputation: 6661
use MySQL LEFT :-
LEFT(names , 1)
query like that :-
select LEFT(names , 1) from table
Upvotes: 3