I have a query I'm trying to run in my php code and it is only returning one result, but if i run the same query in phpmyadmin it works. Can anyone tell me where I'm going wrong?
<?php
$sql = "SELECT * FROM `product_packs` WHERE `name` IN('" . implode("', '", $_SESSION['cart_items']) . "')";
$result = $conn->query($sql);
if ($result->num_rows > 0){
while($row = $result->fetch_assoc()){
echo "<div class='col-xs-6 col-sm-4 col-md-2 col-lg-2'>
<div class='products " . $row['brandName'] . " all " . $row['product_range'] . "' id='products'>
<div class='hovereffect'>
<img class='img-responsive productimg' src='" . $row['img'] . "' alt=''>
<div class='overlay1'>
<h2> " . $row['name'] . "</h2>
<p>
" . $row['title'] . "
<br>
<br>
" . $row['price'] . "
<br>
<a href='remove_from_cart.php?name=" . $row['name'] . "&price=" . $row['price'] . "'>
Remove From Cart
</a>
</p>
</div>
</div>
</div>";
}
?>
I have printed the query to make sure the result of the implode is correct and it seems to be as i can run the result in phpmyadmin and it works fine.
Any help would be appreciated.