如何将javascript的值传递给PHP变量并存入mysql数据库? [英] How to pass the value of javascript into a PHP variable and stored into mysql database?
问题描述
我试图从javascript获取值并存储到MySQL数据库中。并根据数据库的输出值重新显示值。
所以我需要知道如何在MySQL数据库中存储javascript值?
我尝试了什么:
任何人都可以帮助我。
Js:
var age = new Date()。getFullYear() - getYearInteger();
在php页面:
$ sql =INSERT INTO表达式(id,年龄)VALUES('','$ age');
但它在mysql数据库中存储值为0。如何在ajax中调用函数并将值存储在数据库中
I am trying to get values from javascript and stored into MySQL database. and reterive the values based on the output values from database.
So I need to know How to store the javascript values in MySQL database?
What I have tried:
can anyone help me.
Js:
var age = new Date().getFullYear()-getYearInteger();
in php page :
$sql="INSERT INTO expression (id, age) VALUES ('','$age')";
but it is stored value 0 in mysql database. how to call function in ajax and store the values in database
推荐答案
sql =INSERT INTO表达式(id,age)VALUES('','
sql="INSERT INTO expression (id, age) VALUES ('','
age');
但它在mysql数据库中存储值为0。如何在ajax中调用函数并将值存储在数据库中
age')";
but it is stored value 0 in mysql database. how to call function in ajax and store the values in database
当你插入字符串值时发生这种情况('
That happened when you insert string value ('
这篇关于如何将javascript的值传递给PHP变量并存入mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!