Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何检查输入的变量是否作为主键存在于MySQL数据库中_Php_Android_Mysql - Fatal编程技术网

Php 如何检查输入的变量是否作为主键存在于MySQL数据库中

Php 如何检查输入的变量是否作为主键存在于MySQL数据库中,php,android,mysql,Php,Android,Mysql,我想检查我在android应用程序(加载到android设备)上输入的变量是否存在于我的MySQL数据库中 这是我的密码 tav_enterstudentno.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" andro

我想检查我在android应用程序(加载到android设备)上输入的变量是否存在于我的MySQL数据库中

这是我的密码

tav_enterstudentno.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<Button
    android:id="@+id/btn_enterstudentno"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="74dp"
    android:text="Enter Student No" />

<TextView 
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/btn_enterstudentno"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="46dp"
    android:text="TextView" />

</RelativeLayout>
这就是我想要发生的事情;当按下btn_enterstudentno时,将弹出一条警告消息,要求用户输入学号。如果在弹出的警告消息中按下OK按钮,并且假设用户已在警告消息文本字段中键入内容,程序将检查输入的学号是否是某个MySQl数据库中某个表的主键


提前谢谢你

android无法直接与mysql对话。您需要一个web服务(例如php脚本)从android获取一些http get/post参数,然后以某种格式(例如json)返回结果。是的,但是您能帮我处理php文件吗?我已经有了本教程中的jsonparser类,谢谢
public class MainActivity extends Activity {

Button btn_enterstudentno;
TextView throwhere;

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

@Override
public boolean onCreateOptionsMenu(Menu menu) 
{
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}


public void tavinputswindow()
{
    setContentView(R.layout.tav_enterstudentno);

btn_enterstudentno = (Button)this.findViewById(R.id.btn_enterstudentno);
btn_enterstudentno.setOnClickListener(new View.OnClickListener() 
{
    public void onClick(View arg0) 
    {
        enterstudentno(); //POPS UP DIALOGBOX ASKING FOR STUDENT NO.
    }
});
}

//POPS UP DIALOGBOX ASKING FOR STUDENT NO.
    public void enterstudentno()
    {
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle("Enter Student No."); //alert.setMessage("Message");
        final EditText input = new EditText(this); // Set an EditText view to get user input 
        alert.setView(input);
        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() //FOR OK BUTTON
        {
            public void onClick(DialogInterface dialog, int whichButton) 
            {
                String studentno = input.getText().toString();
                //CHECK DATA BASE FOR EXISTENCE OF STUDENT ID NO *****



            }
        });
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener()//FOR CANCEL BUTTON
        {
          public void onClick(DialogInterface dialog, int whichButton) 
          {
             dialog.cancel(); // Canceled.
          }
        });
        alert.show();
    }

}