How Can I Return Results For Items Found. But Also Have A List Of Items Not Found
I currently have a HTML search form which takes multiple inputs (for example: 123456, 654321, 789456). I am using PHP to search a database, to see if the numbers exist as an item n
Solution 1:
The search terms are within your $searchFor
array, so that's already dealt with. Now we only need to find some way to display these instead of a table. Let's modify the code that deals with the results count.
Try something like this:
foreach ($resultsArrayas$key => $results) {
if (count($results) > 0) {
foreach ($resultsas$r) {
echo"<tbody>";
...
echo"</tbody>";
}
} else {
echo"No results found for ". $searchFor[$key];
}
}
You want the count checking to be in your foreach($resultsArray as $results)
. That way you'll check each of the as $results
arrays. The $key contains the index for the current iteration (1st = 0, 2nd = 1, etc.,) so you can use it to access the searchedFor array, which contains your exploded search terms.
Post a Comment for "How Can I Return Results For Items Found. But Also Have A List Of Items Not Found"