[英]How to display first character in drop down list
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. 例如,我在mysql表中有亚当,哈利,詹姆斯的名字。 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. 我创建了一个下拉列表,显示了名称Adam,Harry等。但是,我只想在下拉列表中显示其首个字符,例如A,H,J等。 Is there any way to do it? 有什么办法吗?
Try something like this. 尝试这样的事情。 I hope this will help. 我希望这将有所帮助。
<option value='" . $row['name'] ."'>" . substr($row['name'], 0, 1) ."</option>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.