For some reason this query isnt working.
<p align="center">
<?php
$result1 = mysql_query("SELECT name FROM comics GROUP BY name ORDER BY name ASC");
while ($row = mysql_fetch_array($result1))
{
?>
<a href="?sort=<?php echo substr($row['name'], 0, 1); ?>"><?php echo substr($row['name'], 0, 1); ?></a>
<?php } ?>
</p>
The Output
2 2 3 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A V V V V Z
instead of it going through and grouping by the name and then breaking it down by first letter and just displaying one letter it displays them all.
any help?
You GROUP BY the full name in SQL; than you iterate the result in PHP and display the first letter only; of course if your table contains e.g.
Abc
Ade
Afg
GROUP BY name would return them all; and displaying only the first letter will print “A” three times.
If you only want to retrieve the first letters you could try