Php backtick键位于1键的左侧。如果这仍然不适用于您,请添加print\r($rows)在最后,然后将该输出添加到您的问题中。(代码帖子尝试)(没有像您的帖子那样着色?>)这似乎有效。。但是人是慢的foreach($harNumArray as$harN

Php backtick键位于1键的左侧。如果这仍然不适用于您,请添加print\r($rows)在最后,然后将该输出添加到您的问题中。(代码帖子尝试)(没有像您的帖子那样着色?>)这似乎有效。。但是人是慢的foreach($harNumArray as$harN,php,mysql,match,where,empty-list,Php,Mysql,Match,Where,Empty List,backtick键位于1键的左侧。如果这仍然不适用于您,请添加print\r($rows)在最后,然后将该输出添加到您的问题中。(代码帖子尝试)(没有像您的帖子那样着色?>)这似乎有效。。但是人是慢的foreach($harNumArray as$harNum){$results=mysqli_query($mysqli,“从har_id=$harNum的位置选择guar_num”);if($row=mysqli_fetch_assoc($results)){$guarNum=$row[“gua

backtick键位于1键的左侧。如果这仍然不适用于您,请添加
print\r($rows)在最后,然后将该输出添加到您的问题中。(代码帖子尝试)(没有像您的帖子那样着色?>)这似乎有效。。但是人是慢的
foreach($harNumArray as$harNum){$results=mysqli_query($mysqli,“从har_id=$harNum的位置选择guar_num”);if($row=mysqli_fetch_assoc($results)){$guarNum=$row[“guar_num”];}else{$guarNum=“-”//echo$harNum.\t.“$guarNum”“\r\n
”fwrite($fh,$harNum.\t.$GARNUM.\r\n”);}
$harNumArray = (0100001943,0100001944,0100002392,0100007414,0100012110,0100015761,0100015835);
$harNumArray2 = implode(',', $harNumArray);
$results  = mysqli_query($mysqli, "SELECT har_id, guar_num FROM placements WHERE har_id IN ($harNumArray2)");

//**outputting the matches values/data from the search (select)**

while ($row = mysqli_fetch_assoc($results)) {
    //echo "HAR_ID: ". $row["har_id"]. "\tGUAR_NUM: " . $row["guar_num"] . "\r\n<BR>";
    echo $row["har_id"]. "\t" . $row["guar_num"] . "\r\n<BR>";
    fwrite($fh, $row["har_id"] . "\t" . $row["guar_num"] . "\r\n");
} 
//stack overflow approach:
    //format array data
    $harNumArray2 = "'" . implode("','", $harNumArray) . "'";    //single quotes
    //$harNumArray2 = implode(',', $harNumArray);  //no quotes
    //$harNumArray2 = '"' . implode('","', $harNumArray) . '"';  //double quotes
    //print_r("ARRAY CHECK: " . $harNumArray2);

    $results = mysqli_query($mysqli, "SELECT har_id, guar_num FROM placements WHERE har_id IN ($harNumArray2) ORDER BY har_id ASC") or die(mysql_error());
    //$results = mysqli_query($mysqli, "SELECT har_id, guar_num FROM placements WHERE har_id IN (" . $harNumArray2 . ") ORDER BY har_id ASC") or die(mysql_error());

    echo("<BR>");
    print_r("SELECT har_id, guar_num FROM placements WHERE har_id IN ($harNumArray2)");
    echo("<BR>");

    $rows = array();
    while($row = mysqli_fetch_assoc($results)) {
        $rows[$row['har_id']] = $row;
    }
    foreach ($harNumArray as $id){
        if (isset($rows[$id])){
            //... do something with $rows[$id]
            print_r($rows[$id] . "<BR>");

        }else{
            //... no match for $id
            print_r("....no match....");
            echo("<BR>");
        }
    }
$harNumArray = array(
    '0100001943',
    '0100001944',
    '0100002392',
    '0100007414',
    '0100012110',
);
$harNumArray2 = "'".implode("','", $harNumArray)."'";
$results = mysqli_query($mysqli, "SELECT har_id, guar_num FROM placements WHERE har_id IN ($harNumArray2)");
$rows = array();
while ($row = mysqli_fetch_assoc($results)) {
    $rows[$row['har_id']] = $row;
}
foreach ($harNumArray as $id){

    if (isset($rows[$id])){
        ... do something with $rows[$id]
    }else{
        ... no match for $id
    }
}
$results = mysqli_query($mysqli, "SELECT har_id, guar_num FROM placements LIMIT 5");
while ($row = mysqli_fetch_assoc($results)) print_r($row);