I'm having a little trouble making my pagination script user friendly. I have an array of characters like so:
$character_set = array('#','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
Basically, I want to query the database using the array to check which strings in a field begin with which letters. If a string does not begin with a letter, I still want to display the letter on the page but remove the hyperlink. I also want to remove the hyperlink and make the text bold, whenever the user is on a letter which does have records beginning with it. I have tried using a
foreach() loop in combination with
LIKE in SQL, to get all array values, but no luck. This is my loop and query:
foreach ($character_set as $letters)
{
$query = mysql_query('SELECT film_title FROM ' . REVIEW_ARTICLE_TABLE . ' WHERE film_title LIKE "' . $letters . '%"');
$rows = mysql_fetch_assoc($query);
$film_title = $rows['film_title'];
// I have a feeling this is wrong
if (in_array($film_title['0'],$character_set))
{
echo '<span class="link"><a href="SITEURLHERE/select.php?category=0&letter=' . strtolower($letters) . '">' . $letters . '</a></span>';
}
else
{
echo '<span class="plaintext">' . $letters . '</span>';
}
}
I can see where the issue is - the entire array is being echo'd out rather than separate values, but I'd rather be simple as possible and not have to edit the script at all, whenever I add a record which begins with a new letter.
Thanks in advance. :)