。。。 And then you have to ask for help. I have a problem with my code about how to use arrays as SQL query statements in PHP
There are currently two tables: MHF (meaning models_has_features), MHR (meaning models_has_replacements). One of the MSF fields is model_name and fd_name (meaning feature name), and the MSR field is model_name and rd_name (meaning replacement name).
The user's options for features and replacement are now available through PHP, and they want to search the database using these options to return the model name.
Thanks for the help of the last post, my current relevant code is as follows:
PHP Code
$usrinput 1=array_merge ($outputs, $functions, $qualifications); Here is the user-entered features option, where each variable is an array and is $usrinput2=array_merge by a multiple-selection list ($ge, $ametek, $weschler, $prime, $VMI, $foxboro, $ Bailey, $chessell, $hays); Here is the user-entered replacement option, where each variable is also an array $query 0= "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 ' "; Among them, $power _input, $display, $case _mounting are string variables that are obtained by a user-selected single-selection list $query 1= "and MHF. Fd_name= ' ". Implode (" ' and Fd_name= ' ", $usrinput 1)." ' "; $query 2= "and MHR. Rd_name= ' ". Implode (" ' and Rd_name= ' ", $usrinput 2)." ' "; $query = $query 0. $query 1. $query 2;//This is to combine the three query into a full query to reach the Select Select MHF. M_name from MHF,MHR WHERE MHF. M_NAME=MHR. M_name and MHF. Fd_name= ' $input _signal ' ... and MHF. Fd_name= "Each value in USERINPUT1" and MHR. Rd_name= the effect of "userinput2 values". $result = mysql_query ($query) or Die ("Query failed");
Then it's the output code,
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 "
But after running no display Ah, I guarantee that my test options should have results, but not show, I hope you guys look at my code where the error, thank you!
------Solution--------------------
In your MHF table, M_name is clearly a sort of
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 multiple selections are available, the
M_name in (' Value 1 ', ' Value 2 ', ' Value 3 ' ...) and Fc_name in (' Value 1 ', ' Value 2 ', ' Value 3 ' ...)