Thats part of the glossary. The links are of all the letter a-z, and all the terms of the glossary extracted from the database and displayed on glossary.php page.
[ATTACH]2964[/ATTACH]
Here is the simple MYSQL table I made to hold all the terms.
It has 4 columns, id (auto_increment), word (hold the term), definition(holds definition), and alpha(the first letter of the term for sorting purposes) i.e. if alpha is' a' the word starts with an 'a'
[ATTACH]2965[/ATTACH]
My dilemma is sorting only the results based on the letter of the alphabet clicked on the main glossary.php page.
So far I'm able to loop and display all the records on the glossary.php page. I need to sort or limit what records are displayed.
Here is the code I have so far for displaying the records:thumbup1:
<?php
//connect to the db
include_once('inc/connect.inc.php');
$sql = "SELECT * FROM terms";
$query = mysql_query($sql);
//display a to z in links
$alphabet = range('a','z');
echo '<div class="letter">';
foreach($alphabet as $key){
echo '<form action="glossary.php" method="GET">';
echo '<a href="?s'.$key.'">'.$key.'</a>';
}
echo '</div><!--/end the letter array link group-->';
echo '<div class="clear-both"></div>';
//get data from db
echo '<div id="terms">';
while($data = mysql_fetch_assoc($query)){
//set local vars
$id = $data['id'];
$alpha =$data['alpha'];
$word = $data['word'];
$definition = $data['definition'];
echo '<b>'.$word.'</b><a name="'.$word.'"></a>
<p>'.$definition.'</p>';
}
echo '</div><!--//end terms-->';
?>
My dilemma. :confused:
I don't know how to limit the terms displayed by letter based on clicking the link.
(i'm guessing theres a way to pass the variable from the link to the mysql query, and returning those values to the glossary.php page.)
HELP!?!?! I'm still a newbie....


Sign In
Create Account



Back to top









