... You have to ask for help .. My code has a problem with how PHP uses arrays as the conditions for SQL query statements. Currently, there are two tables: mhf (models_has_features) and mhr (models_has_replacements ). the msf fields are Model_Name and FD_Name (meaning Feature... You have to ask for help .. My code has a problem about how PHP uses arrays as the conditions for SQL query statements.
Currently, there are two tables: mhf (models_has_features) and mhr (models_has_replacements ). here, msf fields are Model_Name and FD_Name (meaning Feature Name), and msr fields are Model_Name and RD_Name (meaning Replacement Name ).
Now, you can use php to obtain the features and replacement options. you want to use these options for database search and then return the model name.
Thanks to the help of the moderator in the previous post, my current code is as follows:
PHP code
$ Usrinput1 = array_merge ($ outputs, $ functions, $ qualifications); // Here is the features option entered by the user, where each variable is an array, from the multi-choice list $ usrinput2 = array_merge ($ ge, $ ametek, $ weschler, $ prime, $ vmi, $ foxboro, $ bailey, $ chessell, $ hays ); // Here is the replacement option entered by the user, where each variable is also an array $ query0 = "SELECT mhf. m_Name FROM mhf, mhr WHERE mhf. m_Name = mhr. m_Name AND mhf. FD_Name = '$ input_signal' AND mhf. FD_Name = '$ power_input' AND mhf. FD_Name = '$ display' AND mhf. FD_Name = '$ Case_mounting' "; // where $ power_input, $ display, $ case_mounting are string variables, which are obtained from the selected radio list $ query1 =" AND mhf. FD_Name = '". implode ("'AND FD_Name ='", $ usrinput1 ). "'"; $ query2 = "AND mhr. RD_Name = '". implode ("'AND RD_Name ='", $ usrinput2 ). "'"; $ query = $ query0. $ query1. $ query2; // Here we want to combine these three queries into a complete query to achieve select SELECT mhf. m_Name FROM mhf, mhr WHERE mhf. m_Name = mhr. m_Name AND mhf. FD_Name = '$ input_signal '... AND mh F. FD_Name = "userinput1 values" AND mhr. RD_Name = "userinput2 values. $ Result = mysql_query ($ query) or die ("Query failed ");
Then the code is output,
PHP code
print "
\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print "\t
\n"; foreach ($line as $col_value) { print "\t\t
$col_value | \n"; } print "\t
\n"; } print "
\n";
However, no display is displayed after running. I promise that my test options should have results, but they cannot be displayed. I hope you can see what went wrong with my code. thank you!
------ Solution --------------------
In your mhf table, M_Name is obviously a classification.
Then, the incoming data
Who corresponds to M_Name
Who corresponds to FD_Name
The conditional expression should be
M_Name = 'value' AND FC_Name = 'value'
If you can select multiple, it is
M_Name in ('value 1', 'value 2', 'value 3 '...) AND FC_Name in ('value 1', 'value 2', 'value 3 '...)