PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,477 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,761 people online right now. Registration is fast and FREE... Join Now!




Alphabetical grouping question

 

Alphabetical grouping question, Looking to add links at the top of the page

jeansymolanza

15 Nov, 2008 - 02:28 PM
Post #1

New D.I.C Head
*

Joined: 20 Feb, 2008
Posts: 35


My Contributions
Hi guys I'm in the process of building a Physics school website but I'm stuck at the moment. I need to create hyperlinks at the top of the page that will jump to the section of the page where the alphabet the user has clicked on begins. Here is my code so far.

I've successfully been able to create individual groupings for each letter. But how do I create hyperlinks at the top of the page linking to each grouping to to facilitate overall usabilty.

Much thanks in advance.

CODE

<span class="body">Use the search feature if you are looking for something specific.</span><p>
<form action="" method="post"><input name="" type="text" style="background: #fffff;border: 1px solid #c3c3c3; width: 200px;"/>&nbsp
<input name="" type="button" value="Search!"/></form>
          <table width="100%" cellspacing="0" cellpadding="0">
<?  
$sql = "SELECT * FROM tbl_topics ORDER BY title ASC";
$results = mysql_query($sql);
$letter = '';
while( $row = mysql_fetch_assoc($results) ) {
  if( $letter !== strtoupper($row['title'][0]) ) {
    $letter = strtoupper($row['title'][0]);
    echo '<tr><td><img src="../img/spacer.gif" height="10px"></td></tr>' . '<tr><td class="subheading2" style="border-bottom: #333333 inset 1px; padding-bottom: 5px;">' . $letter, '</tr></td>';
  }
  echo '<tr><td class="body2" style="border-bottom: #999999 inset 1px; padding-top:5px; padding-bottom: 5px;">' . '<img src="../img/topics.gif"/>&nbsp' . '<a href="#">' . $row['title'], '</a>' . ' ' . '<span class="body4"> @ ' . $row['date'] . ' ' . $row['time'] . ' in ' . $row['category'] .'</span>' . '</td></tr>';
}
?>        
</table>


User is offlineProfile CardPM
+Quote Post


Valek

RE: Alphabetical Grouping Question

15 Nov, 2008 - 02:31 PM
Post #2

The Real SkyNet
Group Icon

Joined: 8 Nov, 2008
Posts: 625



Thanked: 43 times
Dream Kudos: 175
My Contributions
If the alphabetic list isn't ever going to change, you could just use anchors. If it is, you could have it look at the first letter of each one, and echo an anchor whenever it changes to the next letter in the alphabet.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 03:37AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month