Cocos2d-x curl+php Network programming do leaderboard (a) cocos2d x download mescaline lai quick cocos2d x

Source: Internet
Author: User
In order to try the network programming, read a lot of great God's blog, now this record to prevent forgetting.

We have to do a few things before we write the connection code:

1. Build Wamp

2. Create a database

3. Write the PHP code well

4. Testing

First, the installation of Wamp

This is relatively simple, I have to find a installation package from the Internet installed OK.

Second, create a database

I went to the Internet under a navicat for MySQL, you can visualize the database operation, convenient later operation. (1) Fill in the above IP, the user name, the password is good; (2) Create a new database in the connection user; (3) Create a new table in the new database, then click on the design table creating the data name and the data type you need, and finish the preparation of the database. Here's what to prepare for PHP.

Third, write a good php file: rank.php

My code is for my flappybrid to do the leaderboard, the code is as follows:

 $score _max)//If the same name is compared with the previous data, if it is larger than the previous update data {$sql = "Update user set score= ' $score _ ' where name= ' $name _ '"; mysql_query ($sql );}} else{//Insert new data with the same name $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
 
  <><11);$count++) { 选出前十并输出 ="" $li="$row['name']; " echo="" $row['name']."-="">"; echo $row [' score ']; if ($count 
   <11);$count++) {>
 
Iv. Enter the URL in the browser http://127.0.0.1/rank.php?name=bak&score=7758

The page shows bak->7758, and you can add a few more different data.

The above describes the Cocos2d-x curl+php network programming to do the leaderboard (a), including the cocos2d-x aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.