我想做这样的Mysql查询:
$sql = mysql_query("SELECT * FROM myTable WHERE id='11' AND number='23' AND value='45' AND result='101' ");
我想使用 '$myArray' 数组元素更改 mysql_query 的 WHERE 变量。
$myArray[0] = array(11, 23, 45, 101); => this is the current query
$myArray[1] = array(21, 31, 70, 58);
$myArray[2] = array(8, 77, 68, 94);
我试图得到这样的结果:
foreach($myArray[] as $singleRow) {
foreach($singleRow as $myElement) {
$sql = mysql_query("SELECT * FROM myTable WHERE id='". $myElement ."' AND number='". $myElement ."' AND value='". $myElement . "' AND result='". $myElement ."' ");
}
}
或者像这样:
for ($i=0; $i<count($myArray); $i++) {
foreach($myArray[$i] as $myElement) {
$sql = mysql_query("SELECT * FROM myTable WHERE id='". $myElement ."' AND number='". $myElement ."' AND value='". $myElement . "' AND result='". $myElement ."' ");
}
}
两者都是错误的......如何做正确的?
谢谢