duanre1891 2019-04-06 15:05
浏览 35

有没有办法在模态中插入$ 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...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥15 一道python难题3
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试