PHP Code:
$letters = 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');
foreach($letters as $letter) {
$getfilms = mysql_query("select films.film_id,films.film_title,films.mobile
, case when substring_index(film_title,' ',1)
in ('a','an','the')
then concat(
substring(film_title,instr(film_title,' ')+1)
,', '
,substring_index(film_title,' ',1)
)
else film_title
end as title2
from films
where case when substring_index(film_title,' ',1)
in ('a','an','the')
then concat(
substring(film_title,instr(film_title,' ')+1)
,', '
,substring_index(film_title,' ',1)
)
else film_title
end like '$letter%' AND films.mobile='y'
order
by title2 ASC LIMIT 5",$ch)
or die(mysql_error());
$titles = array();
while($films=mysql_fetch_array($getfilms)) {
$titles[] = $films['film_title'];
}
echo $newtitles = implode(", ", $titles);
echo $letter = trim($letter);
echo "<br />";
$updaterow = mysql_query("UPDATE app_db SET films='$newtitles' WHERE letter='$letter' LIMIT 1",$cn);
}
This responds instantly, but I am hitting a weird bug. It is not updating rows e, h, j, k, l, o, u, v, w. I checked and can see films are showing under each letter (so not a blank insert), but the table remains blank in those rows. Why is that?
Bookmarks