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!