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?

2nd Jul 2020, 8:57 PM
newbiecoder
9 ответов
+ 3
newbiecoder Already explained in shared link. You can get using $_REQUEST like $name = $_REQUEST["name"]
3rd Jul 2020, 7:19 AM
A͢J
A͢J - avatar
+ 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.
2nd Jul 2020, 9:46 PM
A͢J
A͢J - avatar
+ 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.
2nd Jul 2020, 9:35 PM
A͢J
A͢J - avatar
+ 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.
2nd Jul 2020, 9:42 PM
A͢J
A͢J - avatar
+ 1
okay thanks, i have never ever used ajax so ill try to add this into a html form for now
2nd Jul 2020, 9:44 PM
newbiecoder
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
2nd Jul 2020, 9:33 PM
newbiecoder
0
yes but the info i need to insert is not from a form, its information extracted from another link
2nd Jul 2020, 9:38 PM
newbiecoder
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?
2nd Jul 2020, 9:59 PM
newbiecoder