In order to try network programming, I read a lot of blogs by great people, so I will record this now so as not to forget it.
Before writing the connection code, we must do a few things first:
1. Build WAMP
2. Create a database
3. Write the PHP code
4. Test
1. Installation of wamp
This is relatively simple. I found an installation package from the Internet and installed it.
2. Create a database
I went online and downloaded Navicat for MySQL, which can visually operate the database and facilitate future operations. (1) Just fill in the IP, user name, and password above; (2) Create a new database user in the connection; (3) Create a new table in the newly created database, and then click Design Table to create what you need Data name and its data type; after completing the above steps of database preparation, the following is the preparation of PHP.
3. Write the PHP file: rank.php
This code is for my flappybrid to make rankings. The code is as follows:
$score_max) //如果有同名就跟之前的数据比较,如果比之前大就更新数据 { $sql="update user set score='$score_' where name='$name_'"; mysql_query($sql); } } else {//同名就插入新数据 $sql="insert into user(name,score) values('$name_','$score_')"; mysql_query($sql); } $li="select* from user where 1 = 1 order by score desc"; $result=mysql_query($li,$link); for($count=1;($row=mysql_fetch_array($result)) &&($count"; echo $row['score']; if($count
The page displaysbak->7758, and you can add different data several times.
The above introduces the cocos2d-x curl+PHP network programming ranking list (1), including the content of Cocos2d-X. I hope it will be helpful to friends who are interested in PHP tutorials.