I have an array:. Now I want to fetch data from product table by using this part of code:PHP Code:productid = [1,2]
when I returned the names as follow:Code:$sql = 'SELECT name FROM product WHERE id=:id'; $s = $pdo->prepare($sql); foreach($productid as $id) { $s->bindValue(':id', $id); $s->execute(); }
I just got the product name of second id and didn't get both names. What's the problem?Code:foreach($s as $row) { $name[] = array( 'name' => $row['name'] ); }


Reply With Quote

Bookmarks