2
I am developing a website, in which I have several products, for example and a button for each of them.
When I click the button, it opens a modal (Bootstrap).
But, I want to generate the content of this modal, or the whole modal even dynamically with a Function in PHP
For example, a product with the data
Nome: Carro,
Valor: 3,000.
Then I send the information to the function:
gerarmodal($nome, $valor);
And she returns to me the modal, or her content, with the values of the variables in their proper places.
"You are buying a Car, for the amount of 3,000 reais."
I know it is necessary to use javascript together with php, to request the data without refresh. I’ve tried but I can’t come up with a logic to make it work.
How could I do that and display the modal on my page?
Hello, welcome to Stackoverflow! I don’t think you can do this using PHP, since it runs inside the server. Only if you call a page. php inside the modal with iframe, or call inside a div superimposed on the rest of the page (modal) or something similar. But I believe it is easier to be solved using Ajax requests.
– Avelino
Yes. I forgot to mention that javascript would be needed, along with PHP. ?
– Jhonatan Silva
Search on AJAX, then put a System in the boot that runs AJAX and put the data in the modal.
– Olimon F.
Take a look here: http://answall.com/q/6626/129
– Sergio