السلام عليكم
اريد شرح مفصل كيفيه اظهار معلومات من قاعده البيانات في الاندرويد
فكره برنامجي هي عمل search لمواقع سجلتها في قاعده البيانات ولكن اريد ان افهم كيف اطبق الفكره واحظر المعلومات عندما يبحث المستخدم عن موقع معين واظهارها في الاندرويد
اريد الطريقه ضروري لو سمحتو
وايضا عندي مشكله في عرض البيانات لمستخدم معين
الفكره هي عندما يتم تسجيل دخول المستخدم تظهر له جميع بياناته المسجله مسبقا في قاعده البيانات ولكن عندي مشكله ولا تظهر عندي البيانات
<?php
$response = array();
require_once 'include/DB_Functions.php';
// connecting to db
$db = new DB_Functions();
// check for post data
//if ( isset($_POST["DrNo"]) )
//{
//$DrNo = $_POST['DrNo'];
$DrNo = $_GET['DrNo'];
//$DrNo =12345676;
// get a driver from driver table
$result = mysql_query("SELECT *FROM driver where DrNo=$DrNo");
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$d = array();
$d["DrNo"] = $result["DrNo"];
$d["DrFName"] = $result["DrFName"];
$d["DrSName"] = $result["DrSName"];
$d["DrTName"] = $result["DrTName"];
$d["DrLName"] = $result["DrLName"];
$d["DrPhoneNo"] = $result["DrPhoneNo"];
$d["DrAdress"] = $result["DrAdress"];
$d["DrEmail"] = $result["DrEmail"];
$d["DrPass"] = $result["DrPass"];
// $d["created_at"] = $result["created_at"];
// $d["updated_at"] = $result["updated_at"];
// success
$response["success"] = 1;
// user node
$response["d"] = array();
array_push($response["d"], $d);
// echoing JSON response
echo json_encode($response);
}
else {
// no driver found
$response["success"] = 0;
$response["message"] = "No driver found";
// echo no driver JSON
echo json_encode($response);
}import java.util.ArrayList;
import java.util.List;
import nct.edu.om.andphpconnection.jsonparser.JSONParser;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
//import org.json.JSONException;
import org.json.JSONObject;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.util.Log;
import android.view.View.OnClickListener;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Detail extends Activity {
private static String detailURL = "http://10.0.2.2/detail.php";
TextView t1;
TextView t2,t3,t4,t5,t6,t7,t8,t9;
Button b1,b2;
String DrNo,DrFName,DrSName,DrTName,DrLName,DrPhone,DrAdress,DrEmail,DrPass;
private ProgressDialog pDialog;
JSONParser jParser = new JSONParser();
private static final String TAG_SUCCESS = "success";
private static final String TAG_DrNo = "DrNo";
private static final String TAG_DrFName = "DrFName";
private static final String TAG_DrSName = "DrSName";
private static final String TAG_DrTName = "DrTName";
private static final String TAG_DrLName = "DrLName";
private static final String TAG_DrPhoneNo = "DrPhoneNo";
private static final String TAG_DrAdress = "DrAdress";
private static final String TAG_DrEmail = "DrEmail";
private static final String TAG_DrPass = "DrPass";
// private static final String TAG_B1 = "b1";
// users JSONArray
//JSONArray Detail = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
b1=(Button)this.findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intentdetail=new Intent(Detail.this,taxi.nct.edu.om.Detail2.class);
startActivity(intentdetail);
}
});
Intent valueintent = getIntent();
String DrNo=valueintent.getStringExtra("DrNo");
/* Starts ---Display hall information from the database using JSON........... */
// Loading users in Background Thread
//new LoadAlldriver().execute();
// Ends here --------------------------------------------------------------------//
// Loading users in Background Thread
new LoadAlldriver().execute();
}
/* Background Async Task to Load all product by making HTTP Request
* */
class LoadAlldriver extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Detail.this);
pDialog.setMessage("Loading Users. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... args) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
// Building Parameters
Intent valueintent = getIntent();
//int DrNo = valueintent.getIntExtra("DrNo");
String DrNo = valueintent.getStringExtra("DrNo");
t1.setText(DrNo);
//String msgtitle=txtProduct.getText().toString();
//List<String> msgresult = new ArrayList<String>();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("DrNo", DrNo));
//JSONObject json = jsonParser.getJSONFromUrl(url_message_detials, params);
// getting message details by making HTTP request
// Note that message details url will use GET request
JSONObject json = jParser.makeHttpRequest(detailURL, "GET", params);
// check your log for json response
Log.d("All Drivers: ", json.toString());
// json success tag
int success = json.getInt(TAG_SUCCESS);
if(success==1){
JSONArray Detail = json.getJSONArray(TAG_DrNo);
// get message from JSON Array
JSONObject c = Detail.getJSONObject(0);
// message with this msg_id found
t1= (TextView) findViewById(R.id.textView3);
t3= (TextView) findViewById(R.id.textView7);
t4= (TextView) findViewById(R.id.textView9);
t5= (TextView) findViewById(R.id.textView11);
t6= (TextView) findViewById(R.id.textView13);
t7= (TextView) findViewById(R.id.textView15);
t8= (TextView) findViewById(R.id.textView17);
t9= (TextView) findViewById(R.id.textView19);
t2= (TextView) findViewById(R.id.textView5);
DrNo = c.getString(TAG_DrNo);
String DrFName = c.getString(TAG_DrFName);
String DrSName = c.getString(TAG_DrSName);
String DrTName = c.getString(TAG_DrTName);
String DrLName = c.getString(TAG_DrLName);
int DrPhone = c.getInt(TAG_DrPhoneNo);
String DrAdress = c.getString(TAG_DrAdress);
String DrEmail = c.getString(TAG_DrEmail);
String DrPass = c.getString(TAG_DrPass);
//int regist= c.getInt(TAG_Regist);
// if(regist==1)
// register.setClickable(true);
// display message data in TextView
t1.setText(DrNo);
t3.setText(DrFName);
t4.setText(DrSName);
t5.setText(DrTName);
t6.setText(DrLName);
t7.setText(DrPhone);
t8.setText(DrAdress);
t9.setText(DrEmail);
t2.setText(DrPass);
}
} catch (Exception e) {
// TODO: handle exception
}
}
});
return null;
}
}
}هذا كود ال php
و java في الاندرويد
اريد اعرف حلي صحيح وفين المشكله ؟؟