PHP Text Area到MySQL查询变量不会返回所有行结果

I am using a text area in order allow searching of multiple items at once and output the results to a table. Everything works fine when only one item is placed into the text area and searched, however the query results of the first line/search item are not returned if more than one item is searched. My code:

<textarea name="search_items" rows="2" cols="30"></textarea>

$input = $_POST['search_items'];
list($pc1, $pc2) = explode("
", $input);

$desc = mysqli_query($my_connection,"SELECT PART_DESC FROM inventory WHERE PARTCODE = '$pc1' OR PARTCODE = '$pc2';");

$i=1;
while($row_desc = mysqli_fetch_assoc($desc)) { 
    ${'pc_desc'.$i} = $row_desc['PART_DESC']; 
    $i++; 
} 

<table>
    <tr>
        <td><?php echo "$pc1"; ?></td>
        <td><?php echo $pc_desc1; ?></td>
    </tr>
    <tr>
        <td><?php echo "$pc2"; ?></td>
        <td><?php echo $pc_desc2; ?></td>
    </tr>
</table>

$pc1 echos out line 1 of the text area and $pc2 echos out line 2 of the text area. I get the correct results echoed out for $pc_desc2 but $pc_desc1 is blank. If I manually assign $pc1 and $pc2 like this:

$pc1 = "ABC";
$pc1 = "XYZ";

both $pc_desc1 and $pc_desc2 return correctly. Please Help!

Without fixing your SQL injection problems, you'd be better off using something like this:

...
$parts = explode("
", $input);
$sql = "SELECT ... PARTCODE IN (" . implode(',', $parts) . ");";
...
while($row_desc = mysqli_fetch_assoc($desc)) { 
    $data[$row['PART_CODE']] = $row['PART_DESC'];
}

<table>

foreach($data as $code => $desc) {
    echo "<tr><td>$code</td><td>$desc</td></tr>
}

With your code, you have NO guarantee which order the descriptions come back in, and could end up "crossing" things, so you have part #1 with description #2, and part #2 with description #1. The above code guarantees that codes/descriptions are always properly associated together. And also dispenses with dynamic variable names, which make for difficult-/impossible-to-debug code. As well, the above code could handle an arbitrary number of codes, while yours is limited to 2.