Alphabetical Navigation Bar
Moderator: General Moderators
Alphabetical Navigation Bar
Hi everybody,
I would like to add to the web site am constructing an aphabetic navigation bar so that users can browse the database according to the song name. What I actually want to do is to redirect a user when they click on, say letter B, a pgae which is going to display all the songs starting with the letter B. Do I need to create a separate database field in my database stating which letter the song begins with or there is a way I can do it by just extracting the first letter of each song from the field that already exists about the song names. I hope I made myself clear and didnt confuse you.
Thanks a lot!
I would like to add to the web site am constructing an aphabetic navigation bar so that users can browse the database according to the song name. What I actually want to do is to redirect a user when they click on, say letter B, a pgae which is going to display all the songs starting with the letter B. Do I need to create a separate database field in my database stating which letter the song begins with or there is a way I can do it by just extracting the first letter of each song from the field that already exists about the song names. I hope I made myself clear and didnt confuse you.
Thanks a lot!
Tried to do what you say by performing a direct query to my database in the form:
and although there is a song on my database starting with f I get an empty set back as a return of my query....
Code: Select all
select song_name from uploads where song_name='f%';Ok, what Ive done is I have created a small script to display all the alphabet letters which is:
and then another one to display the database entries which is
The script is running but is returning me all the entries of the database. Any idea why? 
Code: Select all
<?php
echo 'This is a test';
echo '<br>';
for ($i = 'A'; $i != 'AA'; $i++) {
echo '<a href="test_t.php?i='.$i.'">ї'.$i.']</a>';
}
?>Code: Select all
<?php
require_once('mysql_connect.php');
$query = "SELECT * FROM uploads WHERE song_name LIKE '$i%' ";
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC))
{
echo "<a href={$rowї'song_name']}>" . ($rowї'song_name']) . "</a>";
}
?>