有没有办法在模态中插入$ name

I have packages on my store. The names, prices, description, etc.. are defined by variables. $name $price $small_desc

I've made a modal, and I'm trying to use those "variables" in it. This way when a player click for more informations, it will show a different package name on each modal.

The issue is, right now it's only displaying '.$name.'

Here you can visualize it by clicking on a package. https://royalkingdom.net/store/?cat=1

I've tried inserting the modal in a php section but it didn't work. I've also tried moving the location of my modal in my code and it didn't work.

<div id="myModal" class="modal">
  <div class="modal-content">
    <div class="modal-header">
      <span class="close">&times;</span>
      '.$name.'
    </div>
    <div class="modal-body">
      <p>Some text in the Modal Body</p>
      <p>Some other text...</p>
    </div>
    <div class="modal-footer">
      Modal Footer
    </div>
  </div>
</div>
if(mysqli_num_rows($result) > 0) {
                        while($post=mysqli_fetch_assoc($result)) {
                            $image=$post['imageurl'];
                            $name=$post['name'];
                            $text=$post['description'];
                            $price=$post['price'];
     $small_desc = implode(' ', array_slice(explode(' ', $text), 0, 15))."";
     $it = exif_imagetype($image);

echo'
  <div class="package">                      
  <div class="package-image">
    <img src="'.(isset($image) && $image!="" && ($it == 1 || $it == 3 || $it == IMG_JPEG) ? $image : "img/404.jpg").'" class="item-img">
    <span class="tooltiptext">Click for Details</span>
 </div> 
<div class="info">
  <div class="text">
    <div class="name">'.$name.'</div>
    <div class="price">'.$price." " .$currency_simbol."USD".'</div> 
    <div class="buy">
    <a href="./product.php?item='.$name.'" class="buy">Buy</a>
</div>
</div> 
</div>   
</div> ';

I'm looking to have my "variables" display when I open a modal. This way each packages modal will have a different title, description, price, etc...