I created an array:
$alphabet = range('A', 'Z');
Which created a list of all of the letters of the alphabet. Then I used a for loop to print out all of the letters of the alphabet:
<ul>
<? for ($i = 0; $i < 26; $i++): ?>
<li><span class="head-menu"><?= $alphabet[$i]; ?></span>
<ul>
<li><a href="#">Some Item</a></li>
<li><a href="#">Some Item</a></li>
</ul>
</li>
<? endfor ?>
</ul>
In that code, I want to replace:
<li><a href="#">Some Item</a></li>
With a list of values from a database such that the first letter of the value in the name column in the database is the same letter as $alphabet[i].
So for example, if I have a database called "food" with just a "name" field, I want an output as such:
A
Apple
B
Banana
C
Carrots
Crackers
Where Apple, Banana, Carrots and Crackers are values in the database.
How can I go about doing this?