为什么我的查询在phpmyadmin中工作但在我的php中却没有?

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.

Try the following (NOT tested as far as I have not sufficent data provided form you):

UPDATED:

<?php
$sql = "SELECT * FROM `product_packs` WHERE `name` IN('" . implode("', '", $_SESSION['cart_items']) . "')";

// dump the query send to the database  
$var_dump($sql);

$result = $conn->query($sql);

if ($result->num_rows > 0){

    $resultset_count = $result->num_rows;
    // dump the number of resultsets in the query
    var_dump($resultset_count);

    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>
            </div>";
    }

?>

Why don't you use FIND_IN_SET? It will work for you, I don't know your database structure but I have created an example query that could be of help for you

why don't use FIND_IN_SET? it will work for you i don't know your database structure still i have created query for you it might help you

SELECT * FROM product_packs
   WHERE (
      FIND_IN_SET(cart_items, (SELECT cart_items   TABLENAME
          WHERE cart_items = '$_SESSION['cart_items']')
      )
   )
ORDER BY `product_id` ASC