Advertisement

06.26.2008 at 04:40PM PDT, ID: 23520220
[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.2

Searching MySQL field for multiple keywords

Asked by prbrowne in MySQL Server, PHP Scripting Language, SQL Query Syntax

Tags:

Hi

I have Flash application where the user can type in a question and it returns a path to a video which is then played.  The MySQL database has two tables, patient_1_question and patient_1_answer.  The answer table is comprised of two fields; answer_id and answer_path (which contains rows for relative paths to a number of videos).  The question table is comprised of three fields; question_id, answer_id (foreign key to the answer table rows) and terms.  Terms contains keywords which if matched retrieves the corresponding path to a video from the answer table through a SQL query - see code snippet.  This works fine when there is a match for a single word in the terms field, but where there are keywords which are the same in multiple rows, the query does not work.  

What I want to do is match multiple keywords contained in the string sent to the PHP file by Flash (contained in the variable $question in the PHP below).  I gather from some research that I need to explode the string and do some sort of loop, but I am not sure how to do this with the current script.  What I would really like is for some kind and knowledgable person to modify the PHP script for me!!

Thanks for any help!

Cheers,

Peter



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
<?php 
require_once('../../connection/nps.php'); 
 
mysql_select_db($database, $connection);
 
$question = $_POST['question'];
 
$query = "SELECT patient_1_answer.answer_path FROM patient_1_question,patient_1_answer WHERE patient_1_question.answer_id=patient_1_answer.answer_id AND MATCH (patient_1_question.terms) AGAINST ('%$question%')";
 
$result = mysql_query($query, $connection) or die(mysql_error());
 
$num_rows = mysql_num_rows($result); 
 
if ($num_rows == 1) {
$counter = 0;
 
while($row = mysql_fetch_array($result)){ 
echo "answer$counter=$row[answer_path]&";
$counter++;
}
echo "counter=$counter"; 
} 
 
elseif ($num_rows > 1){
 
echo "counter=$num_rows";
} 
 
elseif ($num_rows == 0){
echo "counter=0"; 
}
?>
[+][-]06.26.2008 at 09:07PM PDT, ID: 21880918

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.

 
[+][-]06.26.2008 at 09:15PM PDT, ID: 21880937

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.

 
[+][-]06.26.2008 at 09:16PM PDT, ID: 21880944

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.

 
[+][-]06.26.2008 at 09:28PM PDT, ID: 21880987

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.

 
[+][-]06.26.2008 at 11:20PM PDT, ID: 21881293

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, SQL Query Syntax
Tags: PHP, MySQL, ActionScript
Sign Up Now!
Solution Provided By: prbrowne
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628