如何在wampserver中存储数据

时间:2016-04-27 03:30:31

标签: java android mysql database android-studio

public class activityresult2 extends Activity {

static public String txtOrder ="";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_activityresult2);

    Bundle bundle = getIntent().getExtras();
    String strfnq = bundle.getString("Noodle quantity");
    String strfrq = bundle.getString("Rice quantity");
    String strfsq = bundle.getString("Fish quantity");
    String stricq = bundle.getString("Iced tea");
    Integer strsum = bundle.getInt("sum");

    boolean addNingc = bundle.getBoolean("ANI");
    boolean addRingc = bundle.getBoolean("ARI");
    boolean addFingc = bundle.getBoolean("AFI");
    boolean addTingc = bundle.getBoolean("AIT");
    boolean addmoneyc = bundle.getBoolean("AMY");

    Intent mIntent = getIntent();

    int sum = mIntent.getIntExtra("sum",strsum);
    TextView costtext = (TextView)findViewById(R.id.costtext);
    costtext.setText(String.valueOf(sum));

    TextView foodorders = (TextView) findViewById(R.id.foodordershow);
    foodorders.setText(getIntent().getExtras().getString("Quantity"));

    String addNdlThing = "";
    if (addNingc) { 
        addNdlThing = " with addition of ingredients";
    }

    String addRlThing = "";
    if (addRingc) {
        addRlThing = " with addition of ingredients";
    }

    String addSlThing = "";
    if ( addFingc) {
        addSlThing = " with addition of ingredients";
    }

     String addTeac = "";
    if ( addTingc ) {
        addTeac = " with addition of ingredients";
    }

    foodorders = (TextView) findViewById(R.id.foodordershow);
    if(strfnq.equals("") && strfrq.equals("") && strfsq.equals("")&& stricq.equals("")){
        txtOrder = "Sorry, You've not ordered any thing , please return to previous menu to order";
    }else if (!strfnq.equals("") && !strfrq.equals("") && !strfsq.equals("")&& stricq.equals("")) {
        txtOrder = "Thank you , You've ordered\n" + strfnq + " fried noodle" + addNdlThing +" and\n"+ strfrq
                + " fried rice" + addRlThing +" and\n" + strfsq + " Steam fish " + addSlThing + "and\n" + stricq + " Steam fish " + addTeac;
    } else {
        txtOrder = "Thank you , You've ordered\n";
        if(!strfnq.equals("")){
            txtOrder = txtOrder + strfnq + " fried noodle" + addNdlThing;
        }
        if(!strfrq.equals("")){
            txtOrder = txtOrder + strfrq + " fried rice" + addRlThing;
        }
        if(!strfsq.equals("")){
            txtOrder = txtOrder + strfsq + " Steam fish" + addSlThing;
        }
        if(!stricq.equals("")){
            txtOrder = txtOrder + stricq + " Iced Tea"+ addTeac;
        }
    }
    foodorders.setText(txtOrder);
}

在上一页 activityresult1 中选择我的食物后,我的食物显示在此页面( activityresult2 ), Textview foodorders ....如果我按下此页面上的按钮,我希望 foododers 显示的所有项目都存储在我的wampserver数据库中,这是mysql数据库,任何人都可以知道怎么做

2 个答案:

答案 0 :(得分:1)

首先在localhost环境中配置wamp服务器。为了配置wamp 1)获取机器的ipaddress 2)点击wamp服务器中的putonline按钮。 3)编写一个php脚本来存储mysql中的数据。 4)从你的手机中调用php脚本,如(http://192.168.0.5/package名称/ php文件名)

点击此链接:http://androidprogramz.blogspot.in/2012/07/connect-mysql-database-from-android.html

答案 1 :(得分:0)

您无法直接从Android应用程序连接mysql服务器。您必须创建管理将数据存储在mysql数据库中的服务器端脚本。您可以使用http连接将数据发送到脚本。如果您使用的是PHP,这些出色的教程可以帮助您。

Android - PHP/MYSQL Tutorial

How to connect Android with PHP, MySQL