0
php variable into mysql database
I have this variable: echo $attraction->Id and I need to add this variable into my database with a button, does anyone know how?
9 Réponses
+ 3
newbiecoder Already explained in shared link. You can get using $_REQUEST like $name = $_REQUEST["name"]
+ 2
newbiecoder Go here and see how to do
https://www.tutorialrepublic.com/php-tutorial/php-mysql-insert-query.php
+ 2
newbiecoder You need to learn Ajax. It is very helpful. Because we can insert data in database or get data Without reloading the whole page.
+ 1
newbiecoder In that link there is a form which insert data in database when you click on the button.
When you click on the button then one action perform which call the PHP file where we get the value of form and insert data into the database.
+ 1
newbiecoder But when you are working with button then you need to call the PHP file which can only possible using form tag in Html or you can use Ajax.
+ 1
okay thanks, i have never ever used ajax so ill try to add this into a html form for now
0
i know how to make a query but i dont know how to execute this automaticly with a button that fills in the id for me
0
yes but the info i need to insert is not from a form, its information extracted from another link
0
one more thing, do you have an idea how i can get this value into the post method from the form so i get put it into the query?