Get and show data from MySQL of a single user in the Android appWhich MySQL data type to use for storing boolean valuesShould I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?Static way to get 'Context' in Android?How do I get a YouTube video thumbnail from the YouTube API?How do I pass data between Activities in Android application?Download a file with Android, and showing the progress in a ProgressDialogHow do I get extra data from intent on Android?Get current time and date on AndroidHow to get the sizes of the tables of a MySQL database?
Possible nonclassical ion from a bicyclic system
Is floating in space similar to falling under gravity?
Can a rogue effectively triple their speed by combining Dash and Ready?
Mother abusing my finances
Where can I find the list of all tendons in the human body?
Expenditure in Poland - Forex doesn't have Zloty
Thousands and thousands of words
How was Apollo supposed to rendezvous in the case of a lunar abort?
Select row of data if next row contains zero
How to prevent bad sectors?
How can I offer a test ride while selling a bike?
How can I grammatically understand "Wir über uns"?
Will My Circuit Work As intended?
What does the behaviour of water on the skin of an aircraft in flight tell us?
Could I be denied entry into Ireland due to medical and police situations during a previous UK visit?
What is the indigenous Russian word for a wild boar?
What is game ban VS VAC ban in steam?
Geometry affects line breaking
Differences between “pas vrai ?”, “c’est ça ?”, “hein ?”, and “n’est-ce pas ?”
Can a non-EU citizen travel within the Schengen area without identity documents?
Understanding STM32 datasheet regarding decoupling capacitors
How to properly maintain eye contact with people that have distinctive facial features?
Asking bank to reduce APR instead of increasing credit limit
chmod would set file permission to 000 no matter what permission i try to set
Get and show data from MySQL of a single user in the Android app
Which MySQL data type to use for storing boolean valuesShould I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?Static way to get 'Context' in Android?How do I get a YouTube video thumbnail from the YouTube API?How do I pass data between Activities in Android application?Download a file with Android, and showing the progress in a ProgressDialogHow do I get extra data from intent on Android?Get current time and date on AndroidHow to get the sizes of the tables of a MySQL database?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView
of the Android app.
When the user clicks on the 'Information' button
he must view all his information.
The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.
The android app it shows nothing, the data does not arrive.
I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.
My table in MySQL is called Restaurants
and has 11 fields.
- idR
- LocalName
- MediumPrize
- Country
- Region
- Province
- Cap
- Address
- Telephone Number
My php code is :
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'config.php';
$idR= r285602265407430;
// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
$sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);
echo 'culo';
else
echo "No Results Found.";
echo $json;
$conn->close();
?>
My Java code is :
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
public class Modifica_info_base extends AppCompatActivity
HttpParse_info httpParse = new HttpParse_info();
ProgressDialog pDialog;
// Http Url For Filter Student Data from Id Sent from previous activity.
String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";
String finalResult ;
HashMap<String,String> hashMap = new HashMap<>();
String ParseResult ;
HashMap<String,String> ResultHash = new HashMap<>();
String FinalJSonObject ;
String text;
TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
Button UpdateButton;
String TempItem;
ProgressDialog progressDialog2;
EditText idR;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modifica_info_base);
tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
tNazione = (TextView)findViewById(R.id.textView_nazione);
tRegione = (TextView)findViewById(R.id.textView_regione);
tCitta = (TextView)findViewById(R.id.textView_citta);
tProvincia = (TextView)findViewById(R.id.textView_provincia);
tCap = (TextView)findViewById(R.id.textView_cap);
tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
tEmail = (TextView)findViewById(R.id.textView_email);
tNumero = (TextView)findViewById(R.id.textView_numero_telefono);
idR = (EditText)findViewById(R.id.editText5id);
UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);
TempItem = getIntent().getStringExtra("ListViewValue");
final String text= idR.getEditableText().toString();
//Calling method to filter Student Record and open selected record.
HttpWebCall(text);
UpdateButton.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);
// Sending Student Id, Name, Number and Class to next UpdateActivity.
intent.putExtra("idR", String.valueOf(idR));
intent.putExtra("NomeLocale", Nomeristorante);
intent.putExtra("PrezzoMedio", Prezzomedio);
intent.putExtra("Nazione", Nazione);
intent.putExtra("Regione", Regione);
intent.putExtra("Citta", Citta);
intent.putExtra("Provincia", Provincia);
intent.putExtra("Cap", Cap);
intent.putExtra("Indirizzo", Indirizzo);
intent.putExtra("Email", Email);
intent.putExtra("Telefono", Numero);
startActivity(intent);
// Finishing current activity after opening next activity.
finish();
);
//Method to show current record Current Selected Record
public void HttpWebCall(final String PreviousListViewClickedItem)
class HttpWebCallFunction extends AsyncTask<String,Void,String>
@Override
protected void onPreExecute()
super.onPreExecute();
pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);
pDialog.dismiss();
//Storing Complete JSon Object into String Variable.
FinalJSonObject = httpResponseMsg ;
//Parsing the Stored JSOn String to GetHttpResponse Method.
new GetHttpResponse(Modifica_info_base.this).execute();
@Override
protected String doInBackground(String... params)
ResultHash.put("idR",params[0]);
ParseResult = httpParse.postRequest(ResultHash, HttpURL);
return ParseResult;
HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();
httpWebCallFunction.execute(PreviousListViewClickedItem);
// Parsing Complete JSON Object.
private class GetHttpResponse extends AsyncTask<Void, Void, Void>
public Context context;
public GetHttpResponse(Context context)
this.context = context;
@Override
protected void onPreExecute()
super.onPreExecute();
@Override
protected Void doInBackground(Void... arg0)
try
if(FinalJSonObject != null)
JSONArray jsonArray = null;
try
jsonArray = new JSONArray(FinalJSonObject);
JSONObject jsonObject;
for(int i=0; i<jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
// Storing Student Name, Phone Number, Class into Variables.
Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
Nazione = jsonObject.getString("Nazione").toString() ;
Regione = jsonObject.getString("Regione").toString() ;
Citta = jsonObject.getString("Citta").toString() ;
Provincia = jsonObject.getString("Provincia").toString() ;
Cap = jsonObject.getString("Cap").toString() ;
Indirizzo = jsonObject.getString("Indirizzo").toString() ;
Email = jsonObject.getString("Email").toString() ;
Numero = jsonObject.getString("Telefono").toString() ;
catch (JSONException e)
e.printStackTrace();
catch (Exception e)
e.printStackTrace();
return null;
@Override
protected void onPostExecute(Void result)
tNomeRistorante.setText(Nomeristorante);
tPrezzoMedio.setText(Prezzomedio);
tNazione.setText(Nazione);
tRegione.setText(Regione);
tCitta.setText(Citta);
tCap.setText(Cap);
tProvincia.setText(Provincia);
tIndirizzo.setText(Indirizzo);
tEmail.setText(Email);
tNumero.setText(Numero);
php android mysql
add a comment |
I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView
of the Android app.
When the user clicks on the 'Information' button
he must view all his information.
The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.
The android app it shows nothing, the data does not arrive.
I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.
My table in MySQL is called Restaurants
and has 11 fields.
- idR
- LocalName
- MediumPrize
- Country
- Region
- Province
- Cap
- Address
- Telephone Number
My php code is :
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'config.php';
$idR= r285602265407430;
// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
$sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);
echo 'culo';
else
echo "No Results Found.";
echo $json;
$conn->close();
?>
My Java code is :
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
public class Modifica_info_base extends AppCompatActivity
HttpParse_info httpParse = new HttpParse_info();
ProgressDialog pDialog;
// Http Url For Filter Student Data from Id Sent from previous activity.
String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";
String finalResult ;
HashMap<String,String> hashMap = new HashMap<>();
String ParseResult ;
HashMap<String,String> ResultHash = new HashMap<>();
String FinalJSonObject ;
String text;
TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
Button UpdateButton;
String TempItem;
ProgressDialog progressDialog2;
EditText idR;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modifica_info_base);
tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
tNazione = (TextView)findViewById(R.id.textView_nazione);
tRegione = (TextView)findViewById(R.id.textView_regione);
tCitta = (TextView)findViewById(R.id.textView_citta);
tProvincia = (TextView)findViewById(R.id.textView_provincia);
tCap = (TextView)findViewById(R.id.textView_cap);
tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
tEmail = (TextView)findViewById(R.id.textView_email);
tNumero = (TextView)findViewById(R.id.textView_numero_telefono);
idR = (EditText)findViewById(R.id.editText5id);
UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);
TempItem = getIntent().getStringExtra("ListViewValue");
final String text= idR.getEditableText().toString();
//Calling method to filter Student Record and open selected record.
HttpWebCall(text);
UpdateButton.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);
// Sending Student Id, Name, Number and Class to next UpdateActivity.
intent.putExtra("idR", String.valueOf(idR));
intent.putExtra("NomeLocale", Nomeristorante);
intent.putExtra("PrezzoMedio", Prezzomedio);
intent.putExtra("Nazione", Nazione);
intent.putExtra("Regione", Regione);
intent.putExtra("Citta", Citta);
intent.putExtra("Provincia", Provincia);
intent.putExtra("Cap", Cap);
intent.putExtra("Indirizzo", Indirizzo);
intent.putExtra("Email", Email);
intent.putExtra("Telefono", Numero);
startActivity(intent);
// Finishing current activity after opening next activity.
finish();
);
//Method to show current record Current Selected Record
public void HttpWebCall(final String PreviousListViewClickedItem)
class HttpWebCallFunction extends AsyncTask<String,Void,String>
@Override
protected void onPreExecute()
super.onPreExecute();
pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);
pDialog.dismiss();
//Storing Complete JSon Object into String Variable.
FinalJSonObject = httpResponseMsg ;
//Parsing the Stored JSOn String to GetHttpResponse Method.
new GetHttpResponse(Modifica_info_base.this).execute();
@Override
protected String doInBackground(String... params)
ResultHash.put("idR",params[0]);
ParseResult = httpParse.postRequest(ResultHash, HttpURL);
return ParseResult;
HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();
httpWebCallFunction.execute(PreviousListViewClickedItem);
// Parsing Complete JSON Object.
private class GetHttpResponse extends AsyncTask<Void, Void, Void>
public Context context;
public GetHttpResponse(Context context)
this.context = context;
@Override
protected void onPreExecute()
super.onPreExecute();
@Override
protected Void doInBackground(Void... arg0)
try
if(FinalJSonObject != null)
JSONArray jsonArray = null;
try
jsonArray = new JSONArray(FinalJSonObject);
JSONObject jsonObject;
for(int i=0; i<jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
// Storing Student Name, Phone Number, Class into Variables.
Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
Nazione = jsonObject.getString("Nazione").toString() ;
Regione = jsonObject.getString("Regione").toString() ;
Citta = jsonObject.getString("Citta").toString() ;
Provincia = jsonObject.getString("Provincia").toString() ;
Cap = jsonObject.getString("Cap").toString() ;
Indirizzo = jsonObject.getString("Indirizzo").toString() ;
Email = jsonObject.getString("Email").toString() ;
Numero = jsonObject.getString("Telefono").toString() ;
catch (JSONException e)
e.printStackTrace();
catch (Exception e)
e.printStackTrace();
return null;
@Override
protected void onPostExecute(Void result)
tNomeRistorante.setText(Nomeristorante);
tPrezzoMedio.setText(Prezzomedio);
tNazione.setText(Nazione);
tRegione.setText(Regione);
tCitta.setText(Citta);
tCap.setText(Cap);
tProvincia.setText(Provincia);
tIndirizzo.setText(Indirizzo);
tEmail.setText(Email);
tNumero.setText(Numero);
php android mysql
add a comment |
I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView
of the Android app.
When the user clicks on the 'Information' button
he must view all his information.
The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.
The android app it shows nothing, the data does not arrive.
I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.
My table in MySQL is called Restaurants
and has 11 fields.
- idR
- LocalName
- MediumPrize
- Country
- Region
- Province
- Cap
- Address
- Telephone Number
My php code is :
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'config.php';
$idR= r285602265407430;
// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
$sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);
echo 'culo';
else
echo "No Results Found.";
echo $json;
$conn->close();
?>
My Java code is :
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
public class Modifica_info_base extends AppCompatActivity
HttpParse_info httpParse = new HttpParse_info();
ProgressDialog pDialog;
// Http Url For Filter Student Data from Id Sent from previous activity.
String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";
String finalResult ;
HashMap<String,String> hashMap = new HashMap<>();
String ParseResult ;
HashMap<String,String> ResultHash = new HashMap<>();
String FinalJSonObject ;
String text;
TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
Button UpdateButton;
String TempItem;
ProgressDialog progressDialog2;
EditText idR;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modifica_info_base);
tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
tNazione = (TextView)findViewById(R.id.textView_nazione);
tRegione = (TextView)findViewById(R.id.textView_regione);
tCitta = (TextView)findViewById(R.id.textView_citta);
tProvincia = (TextView)findViewById(R.id.textView_provincia);
tCap = (TextView)findViewById(R.id.textView_cap);
tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
tEmail = (TextView)findViewById(R.id.textView_email);
tNumero = (TextView)findViewById(R.id.textView_numero_telefono);
idR = (EditText)findViewById(R.id.editText5id);
UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);
TempItem = getIntent().getStringExtra("ListViewValue");
final String text= idR.getEditableText().toString();
//Calling method to filter Student Record and open selected record.
HttpWebCall(text);
UpdateButton.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);
// Sending Student Id, Name, Number and Class to next UpdateActivity.
intent.putExtra("idR", String.valueOf(idR));
intent.putExtra("NomeLocale", Nomeristorante);
intent.putExtra("PrezzoMedio", Prezzomedio);
intent.putExtra("Nazione", Nazione);
intent.putExtra("Regione", Regione);
intent.putExtra("Citta", Citta);
intent.putExtra("Provincia", Provincia);
intent.putExtra("Cap", Cap);
intent.putExtra("Indirizzo", Indirizzo);
intent.putExtra("Email", Email);
intent.putExtra("Telefono", Numero);
startActivity(intent);
// Finishing current activity after opening next activity.
finish();
);
//Method to show current record Current Selected Record
public void HttpWebCall(final String PreviousListViewClickedItem)
class HttpWebCallFunction extends AsyncTask<String,Void,String>
@Override
protected void onPreExecute()
super.onPreExecute();
pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);
pDialog.dismiss();
//Storing Complete JSon Object into String Variable.
FinalJSonObject = httpResponseMsg ;
//Parsing the Stored JSOn String to GetHttpResponse Method.
new GetHttpResponse(Modifica_info_base.this).execute();
@Override
protected String doInBackground(String... params)
ResultHash.put("idR",params[0]);
ParseResult = httpParse.postRequest(ResultHash, HttpURL);
return ParseResult;
HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();
httpWebCallFunction.execute(PreviousListViewClickedItem);
// Parsing Complete JSON Object.
private class GetHttpResponse extends AsyncTask<Void, Void, Void>
public Context context;
public GetHttpResponse(Context context)
this.context = context;
@Override
protected void onPreExecute()
super.onPreExecute();
@Override
protected Void doInBackground(Void... arg0)
try
if(FinalJSonObject != null)
JSONArray jsonArray = null;
try
jsonArray = new JSONArray(FinalJSonObject);
JSONObject jsonObject;
for(int i=0; i<jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
// Storing Student Name, Phone Number, Class into Variables.
Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
Nazione = jsonObject.getString("Nazione").toString() ;
Regione = jsonObject.getString("Regione").toString() ;
Citta = jsonObject.getString("Citta").toString() ;
Provincia = jsonObject.getString("Provincia").toString() ;
Cap = jsonObject.getString("Cap").toString() ;
Indirizzo = jsonObject.getString("Indirizzo").toString() ;
Email = jsonObject.getString("Email").toString() ;
Numero = jsonObject.getString("Telefono").toString() ;
catch (JSONException e)
e.printStackTrace();
catch (Exception e)
e.printStackTrace();
return null;
@Override
protected void onPostExecute(Void result)
tNomeRistorante.setText(Nomeristorante);
tPrezzoMedio.setText(Prezzomedio);
tNazione.setText(Nazione);
tRegione.setText(Regione);
tCitta.setText(Citta);
tCap.setText(Cap);
tProvincia.setText(Provincia);
tIndirizzo.setText(Indirizzo);
tEmail.setText(Email);
tNumero.setText(Numero);
php android mysql
I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView
of the Android app.
When the user clicks on the 'Information' button
he must view all his information.
The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.
The android app it shows nothing, the data does not arrive.
I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.
My table in MySQL is called Restaurants
and has 11 fields.
- idR
- LocalName
- MediumPrize
- Country
- Region
- Province
- Cap
- Address
- Telephone Number
My php code is :
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'config.php';
$idR= r285602265407430;
// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
$sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);
echo 'culo';
else
echo "No Results Found.";
echo $json;
$conn->close();
?>
My Java code is :
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
public class Modifica_info_base extends AppCompatActivity
HttpParse_info httpParse = new HttpParse_info();
ProgressDialog pDialog;
// Http Url For Filter Student Data from Id Sent from previous activity.
String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";
String finalResult ;
HashMap<String,String> hashMap = new HashMap<>();
String ParseResult ;
HashMap<String,String> ResultHash = new HashMap<>();
String FinalJSonObject ;
String text;
TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
Button UpdateButton;
String TempItem;
ProgressDialog progressDialog2;
EditText idR;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modifica_info_base);
tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
tNazione = (TextView)findViewById(R.id.textView_nazione);
tRegione = (TextView)findViewById(R.id.textView_regione);
tCitta = (TextView)findViewById(R.id.textView_citta);
tProvincia = (TextView)findViewById(R.id.textView_provincia);
tCap = (TextView)findViewById(R.id.textView_cap);
tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
tEmail = (TextView)findViewById(R.id.textView_email);
tNumero = (TextView)findViewById(R.id.textView_numero_telefono);
idR = (EditText)findViewById(R.id.editText5id);
UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);
TempItem = getIntent().getStringExtra("ListViewValue");
final String text= idR.getEditableText().toString();
//Calling method to filter Student Record and open selected record.
HttpWebCall(text);
UpdateButton.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);
// Sending Student Id, Name, Number and Class to next UpdateActivity.
intent.putExtra("idR", String.valueOf(idR));
intent.putExtra("NomeLocale", Nomeristorante);
intent.putExtra("PrezzoMedio", Prezzomedio);
intent.putExtra("Nazione", Nazione);
intent.putExtra("Regione", Regione);
intent.putExtra("Citta", Citta);
intent.putExtra("Provincia", Provincia);
intent.putExtra("Cap", Cap);
intent.putExtra("Indirizzo", Indirizzo);
intent.putExtra("Email", Email);
intent.putExtra("Telefono", Numero);
startActivity(intent);
// Finishing current activity after opening next activity.
finish();
);
//Method to show current record Current Selected Record
public void HttpWebCall(final String PreviousListViewClickedItem)
class HttpWebCallFunction extends AsyncTask<String,Void,String>
@Override
protected void onPreExecute()
super.onPreExecute();
pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);
pDialog.dismiss();
//Storing Complete JSon Object into String Variable.
FinalJSonObject = httpResponseMsg ;
//Parsing the Stored JSOn String to GetHttpResponse Method.
new GetHttpResponse(Modifica_info_base.this).execute();
@Override
protected String doInBackground(String... params)
ResultHash.put("idR",params[0]);
ParseResult = httpParse.postRequest(ResultHash, HttpURL);
return ParseResult;
HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();
httpWebCallFunction.execute(PreviousListViewClickedItem);
// Parsing Complete JSON Object.
private class GetHttpResponse extends AsyncTask<Void, Void, Void>
public Context context;
public GetHttpResponse(Context context)
this.context = context;
@Override
protected void onPreExecute()
super.onPreExecute();
@Override
protected Void doInBackground(Void... arg0)
try
if(FinalJSonObject != null)
JSONArray jsonArray = null;
try
jsonArray = new JSONArray(FinalJSonObject);
JSONObject jsonObject;
for(int i=0; i<jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
// Storing Student Name, Phone Number, Class into Variables.
Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
Nazione = jsonObject.getString("Nazione").toString() ;
Regione = jsonObject.getString("Regione").toString() ;
Citta = jsonObject.getString("Citta").toString() ;
Provincia = jsonObject.getString("Provincia").toString() ;
Cap = jsonObject.getString("Cap").toString() ;
Indirizzo = jsonObject.getString("Indirizzo").toString() ;
Email = jsonObject.getString("Email").toString() ;
Numero = jsonObject.getString("Telefono").toString() ;
catch (JSONException e)
e.printStackTrace();
catch (Exception e)
e.printStackTrace();
return null;
@Override
protected void onPostExecute(Void result)
tNomeRistorante.setText(Nomeristorante);
tPrezzoMedio.setText(Prezzomedio);
tNazione.setText(Nazione);
tRegione.setText(Regione);
tCitta.setText(Citta);
tCap.setText(Cap);
tProvincia.setText(Provincia);
tIndirizzo.setText(Indirizzo);
tEmail.setText(Email);
tNumero.setText(Numero);
php android mysql
php android mysql
edited Mar 24 at 12:11
halfer
14.9k759121
14.9k759121
asked Mar 24 at 10:15
user11133689
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322720%2fget-and-show-data-from-mysql-of-a-single-user-in-the-android-app%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser
add a comment |
Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser
add a comment |
Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser
Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser
answered Mar 24 at 10:34
Ananth HanimanAnanth Haniman
64
64
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322720%2fget-and-show-data-from-mysql-of-a-single-user-in-the-android-app%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown