日期:2014-05-17 浏览次数:20469 次
$usrinput1=array_merge($outputs,$functions,$qualifications); //这里是用户输入的features选项,其中各个变量均是数组,由多选列表而来 $usrinput2=array_merge($ge,$ametek,$weschler,$prime,$vmi,$foxboro,$bailey,$chessell,$hays); //这里是用户输入的replacement选项,其中各个变量也均是数组 $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'"; //其中,$power_input,$display,$case_mounting 均是字符串变量,是由用户选择的单选列表获取而来 $query1="AND mhf.FD_Name='".implode("' AND FD_Name='",$usrinput1)."'"; $query2="AND mhr.RD_Name='".implode("' AND RD_Name='",$usrinput2)."'"; $query=$query0.$query1.$query2; //这里是想把这三个query组合成一个完整的query,从而达到 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="userinput1里各个值" AND mhr.RD_Name="userinput2里各个值" 的效果。 $result = mysql_query($query) or die("Query failed");
print "<table>\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print "\t<tr>\n"; foreach ($line as $col_value) { print "\t\t<td>$col_value</td>\n"; } print "\t</tr>\n"; } print "</table>\n";