简体   繁体   English

如何将变量数据从 PHP While Loop 传递到 Bootstrap Modal?

[英]How do I pass the variable data from PHP While Loop to Bootstrap Modal?

I'm beyond frustrated.我非常沮丧。 Your help is greatly appreciated!非常感谢您的帮助!

So this website code has a PHP while loop that has unordered list items inside of it.所以这个网站代码有一个PHP while 循环,其中包含无序列表项

How can I modify this code below to get it to work for each person to have their own modal with their different information inside?我如何修改下面的这段代码,让它让每个人都有自己的模态,里面有不同的信息? (This code below is the link above) (下面这段代码是上面的链接)

Note: I tried taking the modal outside the while loop and only put the PHP variables and echo statements for data-target and id .注意:我尝试在 while 循环之外使用模式,并且只为data-targetid放置 PHP 变量和 echo 语句。 But, as you imagined it didn't work outside the while loop.但是,正如您想象的那样,它在 while 循环之外不起作用。

Thank you!谢谢!

This is a javascript problem, not a wordpress loop one.这是一个 javascript 问题,而不是 wordpress 循环问题。 Move the modal out of the loop, this is first.将模态移出循环,这是第一个。 Second, the data of each person can be saved in any div or in the button that opens the modal in each case, it will be easy, in there you add some data-whatever attributes, ie.其次,每个人的数据可以保存在任何 div 或在每种情况下打开模态的按钮中,这很容易,在那里你添加一些数据 - 任何属性,即。 data-descripcion, data-title.数据描述,数据标题。 When the button is clicked, you can pull the data from the button itself and replace the .modal-title y .modal-body with the correct info.单击按钮时,您可以从按钮本身提取数据,并将 .modal-title y .modal-body 替换为正确的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM