我想使用 id
从那张table上,然后我想把他们分成两部分 EditText
. 我真的不知道为什么它不起作用。
我的表有5列: user_id, resumeSubject, resumeText, email, fullname
. 在我的table上,我有一个特别的行,我想它是 resumeSubject
以及 resumeText
领域。
这是我的php文件:
<?php
$con = mysqli_connect("HOST", "UserName", "Password", "Database Name");
$user_id = $_POST["user_id"];
$email = $_POST["email"];
$statement = mysqli_prepare($con, "SELECT * FROM resumeUserList WHERE user_id = ?");
mysqli_stmt_bind_param($statement, "i", $user_id);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $user_id, $resumeSubject, $resumeText, $email, $fullname);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["resumeSubject"] = $resumeSubject;
$response["resumeText"] = $resumeText;
}
echo json_encode($response); ?>
这是我的请求类:
public class Request extends StringRequest {
private static final String REQUEST_URL = "URL";
private Map<String, String> params;
public Request(int user_id, Response.Listener<String> listener) {
super(Method.POST, REQUEST_URL, listener, null);
params = new HashMap<>();
params.put("user_id", user_id +"");
}
@Override
public Map<String, String> getParams() {
return params;
}
}
这是我的 ReceiveActivity
:
public class Receive extends Activity {
private static int user_id;
private static String fullname, email;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_receive);
final EditText resumeSubjectText = (EditText) findViewById(R.id.subjectId);
final EditText resumeTextText = (EditText) findViewById(R.id.massageId);
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success) {
String resumeSubject = jsonResponse.getString("resumeSubject");
String resumeText = jsonResponse.getString("resumeText");
resumeSubjectText.setText(resumeSubject);
resumeTextText.setText(resumeText);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
Request request = new Request(user_id, responseListener);
RequestQueue queue = Volley.newRequestQueue(CommonUserList_User.this);
queue.add(request); }
}
我犯了什么错?
暂无答案!
目前还没有任何答案,快来回答吧!