Advertisement

07.28.2008 at 09:43AM PDT, ID: 23601382
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

Getting correct mysql data

Asked by jareddraper in MySQL Server, PHP Scripting Language, PHP and Databases

Tags: ,

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.php

Here 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>&nbsp;¦&nbsp;";
  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_SELF']."?page=$prev\">&laquo;</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['php_SELF']."?page=$i &letter=$letter\">$i</a> ";
}
}

// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$next\">&raquo;</a>";
}
echo "</p>";

mysql_close();
?>Start Free Trial
[+][-]07.28.2008 at 09:49AM PDT, ID: 22104772

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 09:56AM PDT, ID: 22104825

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 10:04AM PDT, ID: 22104902

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MySQL Server, PHP Scripting Language, PHP and Databases
Tags: PHP/MYSQL, IE
Sign Up Now!
Solution Provided By: ddrudik
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.28.2008 at 12:08PM PDT, ID: 22105934

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628