Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query Critieria Does Not Show What the User Selected

Status
Not open for further replies.

msdbsql

Technical User
Nov 22, 2004
39
0
0
US
I am using the following statement:
$result = mysql_query("SELECT DISTINCT products_to_injuries.product_id, products.product_id, products.product_name, products.gender, products.product_name, products.tci,products.vci,images.product_image, injury.injury_name FROM ((products_to_injuries INNER JOIN products ON products_to_injuries.product_id = products.product_id) INNER JOIN images ON products.product_id = images.product_id) INNER JOIN injury ON products_to_injuries.injury_id = injury.injury_id WHERE (((products.gender)=\"$gender\") AND ((injury.injury_id)=$injury)) AND ((images.gender)=\"$gender\")", $dbh);



The user wants the following criteria to show on the screen above the listed results (based on the user's selections):

Gender (MEN or WOMEN)
Injury Name

However the problem is that the wrong injury name appears.

The injury table has two fields:
injury_id
injury_name

the table has ten rows

Example of data in table
id name
1 break
2 scratch
3 dent
etc

Navigation:
The webform has a link to each ID the user can select from.
Based on the selection a results.php is executed that will show the selected criteria and results.

The user wants the correct selected criteria to show.

Do I need to modify the query? Or edit another statement to make sure that the correct name shows up with the correct ID.

As it is now, If the user selects an injury with ID=1 the name that shows in the criteria does not match.

For example if the user selects
Gender-Men
ID = 1

What is displayed above the results is:
Gender: Men
Injury Name: Dent
(Dent is not the correct name for the ID=1)


What I do know:
A product can have more than one injury and an injury can apply to more than one product.

Injury ID = 1 could apply to more then one product.

Every injury has some products associated with it.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top