I have created a sort on movie titles as show in the url below, the problem is I need titles that start with "the" for example "The Dark Knight" to come up under "Dark" instead of "the". Please help if you know how to fix this issue. Thanks
http://www.bucketsofpopcorn.com/movies.phpHere is the code for the page
<?php
if(empty($_POST)) {
if (isset($_GET['letter'])) {
$letter = $_GET['letter'];
} else {$letter= false; }
echo "<font size=1.5>";
$search = $letter;
$alphabet = 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 ($alphabet as $loop_letter) {
if ($loop_letter == $letter) { echo '<B>'; }
echo "<A HREF=\"movies.php?letter="
. $loop_letter . "\">$loop_letter</A>
¦ ";
if ($loop_letter == $letter) { echo '</B>'; }
}
$letter .= "%";
$sdesc = "*";
$classquery = "";
} else {
$search = $_POST['search'];
$search = "%" . $search . "%";
$sdesc = "%" . $search . "%";
$sclass = $_POST['title'];
$classquery = "AND 'title' = CONVERT( _utf8 '" . $sclass . "' USING tbl_blogrev1 )";
}
include 'config.php';
include 'opendb.php';
// If current page number, use it
// if not, set one!
// Define the number of results per page
$max_results = 5;
$rowsPerPage = 5;
// Figure out the limit for the query based
// on the current page number.
$offset = ($pageNum ) * $rowsPerPage;
if (mysql_errno() != 0 ) {
echo '
';
echo $query . '
';
echo mysql_errno() . ' ' . mysql_error();
exit(0);
}
// Perform mysql query on only the current page number's results
if ($letter) {
$query = "SELECT id, title, blog_title, blog, rating, guest, date FROM tbl_blogrev1
WHERE title LIKE '$letter'
UNION ALL SELECT id, title, blog_title, blog, rating, guest, date FROM tbl_blogrev2
WHERE title LIKE '$letter'
UNION ALL SELECT id, title, blog_title, blog, rating, guest, date FROM tbl_blogrev3
WHERE title LIKE '$letter'
UNION ALL SELECT id, title, blog_title, blog, rating, guest, date FROM tbl_blogrev4
WHERE title LIKE '$letter'
UNION ALL SELECT id, title, blog_title, blog, rating, guest, date FROM tbl_blogrevguest
WHERE title LIKE '$letter'ORDER BY id desc LIMIT $offset, $rowsPerPage";
} else {
$query = "SELECT id, title, blog_title, blog, rating, date FROM tbl_blogrev1
UNION ALL
SELECT id, title, blog_title, blog, rating, date FROM tbl_blogrev2
UNION ALL
SELECT id, title, blog_title, blog, rating, date FROM tbl_blogrev3
UNION ALL
SELECT id, title, blog_title, blog, rating, date FROM tbl_blogrev4
UNION ALL
SELECT id, title, blog_title, blog, rating, date FROM tbl_blogrevguest
order by id desc LIMIT $offset, $rowsPerPage";
}
$result = mysql_query($query);
if (mysql_errno() != 0 ) {
echo '
';
echo $query . '
';
echo mysql_errno() . ' ' . mysql_error();
exit(0);
}
//TO PRINT OUT THE DATA
// keeps getting the next row until there are no more to get
while($saba = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<p><b> <font size=3> <font color=red>";
echo $saba['title'];
echo " <font size=1> </b> <font color=gray>...posted by ";
echo $saba['guest'];
echo "<br></b><font size=2> <hr><font color=orange>";
echo $saba['blog_title'];
echo "<br><font color=black>";
echo $saba['blog'];
echo "<br><i><font color=orange>";
echo $saba['rating'];
echo "<br></i></font>";
echo $saba['date'];
echo "<br><hr><br>";
}
//STOP PRINTING OUT THE DATA
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("
SELECT COUNT(*) as Num FROM tbl_blogrev1 ORDER BY id DESC"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
echo "<p class=\"center\">Pages: ";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['php_SEL
F']."?page
=$prev\">&
laquo;</a>
";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['php_SEL
F']."?page
=$i &letter=$letter\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['php_SEL
F']."?page
=$next\">&
raquo;</a>
";
}
echo "</p>";
mysql_close();
?>
Start Free Trial