不好意思,贴上瘾了,没想到flash+php+mysql这么顺利就搞定了,自己赏跟白沙,哈哈
Flash代码:
//第一桢
var sendLoad:LoadVars = new LoadVars();
var acceptLoad:LoadVars = new LoadVars();
sendLoad.userName = "Billows";
sendLoad.sendAndLoad("../php/conn_db.php", acceptLoad, "POST");
//sendLoad.sendAndLoad("http://localhost/Flash&PHP/php/conn_db.php", acceptLoad, "POST");
acceptLoad.onLoad = function(success) {
if (success) {
var myText = _root.createTextField("Billows", 0, 100, 100, 100, 100);
myText.html = true;
myText.htmlText = this.data;
}
};
flash里和上面的差不多,这里用比较方便的LoadVars类来实现
PHP代码:
<?php
$ userName = $ _POST['userName'];//Flash里传过来的值
$ queryStr="SELECT * FROM username where name='".$ userName."'";//根据此变量查询mysql里数据
mysql_connect("localhost","root","");
//localhost本地数据库
//root用户名
//""密码
mysql_select_db("test");//选择mysql里数据库
$ qr = mysql_query($ queryStr);//执行查询
$ nrows = mysql_num_rows($ qr); //取到符合查询条件的表里总的记录数
for ($ i=0; $ i < $ nrows; $ i++)
{
$ row = mysql_fetch_array($ qr); //取出数组
$ data = $ row['password'].", ".$ row['name']."<br>"; //取出记录
echo "&data=".urlencode($ data)."&";//输出到Flash
}
?>
至于数据库我也接触的少,如果sql用的不熟的话,Mysql数据库,表,字段的建立可以用MySql-front来借助实现,很方便的。
好了,php研究至此,以后要用的时候在研究吧。
Flash代码:
//第一桢
var sendLoad:LoadVars = new LoadVars();
var acceptLoad:LoadVars = new LoadVars();
sendLoad.userName = "Billows";
sendLoad.sendAndLoad("../php/conn_db.php", acceptLoad, "POST");
//sendLoad.sendAndLoad("http://localhost/Flash&PHP/php/conn_db.php", acceptLoad, "POST");
acceptLoad.onLoad = function(success) {
if (success) {
var myText = _root.createTextField("Billows", 0, 100, 100, 100, 100);
myText.html = true;
myText.htmlText = this.data;
}
};
flash里和上面的差不多,这里用比较方便的LoadVars类来实现
PHP代码:
<?php
$ userName = $ _POST['userName'];//Flash里传过来的值
$ queryStr="SELECT * FROM username where name='".$ userName."'";//根据此变量查询mysql里数据
mysql_connect("localhost","root","");
//localhost本地数据库
//root用户名
//""密码
mysql_select_db("test");//选择mysql里数据库
$ qr = mysql_query($ queryStr);//执行查询
$ nrows = mysql_num_rows($ qr); //取到符合查询条件的表里总的记录数
for ($ i=0; $ i < $ nrows; $ i++)
{
$ row = mysql_fetch_array($ qr); //取出数组
$ data = $ row['password'].", ".$ row['name']."<br>"; //取出记录
echo "&data=".urlencode($ data)."&";//输出到Flash
}
?>
至于数据库我也接触的少,如果sql用的不熟的话,Mysql数据库,表,字段的建立可以用MySql-front来借助实现,很方便的。
好了,php研究至此,以后要用的时候在研究吧。
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}