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:
Gender
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
Navigation:
The user form 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.
$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:
Gender
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
Navigation:
The user form 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.