Forum Moderators: open

Message Too Old, No Replies

Highlight the First Character from the output

Hightlight 'A' , 'B' and So on.

         

micro123

3:20 am on Oct 28, 2009 (gmt 0)

10+ Year Member



Hello,

I am displaying the student name from the database sorting by alphabetic order.

How can I hightlight the first character of A and follow with the results

for eg:
<h1>A</h1>
Andy
Adam
.
.
<h1>B</h1>
Bron
Brett
.
.
and so on..

Thanks

rocknbil

4:31 pm on Oct 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard micro123, there may be a way to do this strictly in mySQL, but seems like it would be much easier to do in programming, eg

$heading = '';
$headPrinted = 0;


while (your_results) {
// get first letter, store in variable.
// set it as a capital letter
// if it's changed from the current heading,
// set this as the current heading.
// Otherwise, if it's been printed once, skip printing the head.
// print the results row
}

micro123

3:01 am on Oct 30, 2009 (gmt 0)

10+ Year Member



Hi Rocknbil,

Thank you very much for your explanation.

I got it working.

Great!

Thanks