How do I get current user's input data to show in listview?How do I use PHP to get the current year?How do I get the current date and time in PHP?How to get an enum value from a string value in Java?How do I get PHP errors to display?Get current stack trace in JavaHow do I get a YouTube video thumbnail from the YouTube API?What is the simplest and most robust way to get the user's current location on Android?Getting the Current Working Directory in JavaGet current time and date on AndroidLogin activity with volley, php, mysql after login success intent not go to other activity

Why isn't there a ";" after "do" in sh loops?

How acidic does a mixture have to be for milk to curdle?

Unethical behavior : should I report it?

How could a thief buying plane tickets with stolen credit card details benefit personally?

Is a fighting a fallen friend with the help of a redeemed villain story too much for one book

Trapped in an ocean Temple in Minecraft?

How can I stop myself from micromanaging other PCs' actions?

Is there a reason why I should not use the HaveIBeenPwned API to warn users about exposed passwords?

Checking if an integer is a member of an integer list

Get delta of days by current hour and added delta of days

Is this photo showing a woman posing in the nude before teenagers real?

How to Create an Image for Cantor's *Diagonal Argument* with a Diagonal Oval

Will any serial mouse connect to Classic Macs?

Request for a Latin phrase as motto "God is highest/supreme"

Why did Saturn V not head straight to the moon?

What is "I bet" in German?

Are there any examples of technologies have been lost over time?

"I you already know": is this proper English?

Keeping an "hot eyeball planet" wet

Examples of simultaneous independent breakthroughs

How to start an application when a specific disk is mounted

Print sums of all subsets

Why/when is AC-DC-AC conversion superior to direct AC-Ac conversion?

How to avoid unconsciously copying the style of my favorite writer?



How do I get current user's input data to show in listview?


How do I use PHP to get the current year?How do I get the current date and time in PHP?How to get an enum value from a string value in Java?How do I get PHP errors to display?Get current stack trace in JavaHow do I get a YouTube video thumbnail from the YouTube API?What is the simplest and most robust way to get the user's current location on Android?Getting the Current Working Directory in JavaGet current time and date on AndroidLogin activity with volley, php, mysql after login success intent not go to other activity






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have an app where I use the info provided by the user to get a list of data



Using the code below, I'm getting two different results:



  • When where username = '$username' is presented on the PHP side, I receive just the Toast message. However, ListView remains empty.


  • When I remove where username = '$username' from PHP side, Toast message is displayed and the ListView also shows some content


Could you please help me to undestand why the ListView remains empty on that specific case?



Thanks in advance



Java



public void current_user() 
String url = "http://websie/my.php";

Calendar calendar = Calendar.getInstance();
SimpleDateFormat dayes = new SimpleDateFormat("dd-MM-yyyy");
final String created_date = dayes.format(calendar.getTime());

StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>()
@Override
public void onResponse(String response)
//System.out.println(response);
// Toast.makeText(MainActivity.this,response,Toast.LENGTH_SHORT).show();
Toast.makeText(show_post_all_sales_2x100.this, response.toString(), Toast.LENGTH_SHORT).show();

progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);


, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(show_post_all_sales_2x100.this, error.toString(), Toast.LENGTH_SHORT).show();

)
@Override
protected Map<String, String> getParams()
Map<String, String> params = new HashMap<String, String>();
params.put("username", User.getUsername());
params.put("created_date", created_date);
return params;

;

RequestQueue requestQueue = com.android.volley.toolbox.Volley.newRequestQueue(this);
requestQueue.add(stringRequest);


private class ParseJSonDataClass extends AsyncTask<Void, Void, Void>
public Context context;
String FinalJSonResult;

public ParseJSonDataClass(Context context)
this.context = context;


@Override
protected void onPreExecute()
super.onPreExecute();


@Override
protected Void doInBackground(Void... arg0)

HttpParseClass httpParseClass = new HttpParseClass(HttpURL);

try
httpParseClass.ExecutePostRequest();

if (httpParseClass.getResponseCode() == 200)

FinalJSonResult = httpParseClass.getResponse();

if (FinalJSonResult != null)

JSONArray jsonArray = null;
try

jsonArray = new JSONArray(FinalJSonResult);
JSONObject jsonObject;
Subjects subjects;
SubjectList = new ArrayList<Subjects>();

for (int i = 0; i < jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
String tempName = jsonObject.getString("username").toString();
String tempFullForm = jsonObject.getString("created_date").toString();
subjects = new Subjects(tempName, tempFullForm);
SubjectList.add(subjects);

catch (JSONException e)
// TODO Auto-generated catch block
e.printStackTrace();


else
Toast.makeText(context, httpParseClass.getErrorMessage(), Toast.LENGTH_SHORT).show();

catch (Exception e)
e.printStackTrace();

return null;


@Override
protected void onPostExecute(Void result)
progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);




PHP



<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'DatabaseConfig.php';
$username = $_POST['username'];

// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);


$sql = "SELECT * FROM post_2x where username = '$username'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);

else
echo "No Results Found.";

echo $json;
$conn->close();

?>


Result when where username = '$username' is present



This image when i use (where username = username)



Result when I remove where username = '$username'



This image when i remove (where username = username)










share|improve this question
























  • This looks like Android. You might need to add that tag.

    – Sedrick
    Mar 26 at 17:57






  • 1





    i did thanks ..

    – vorta plus
    Mar 26 at 18:04











  • i need answer...

    – vorta plus
    Apr 2 at 15:57

















0















I have an app where I use the info provided by the user to get a list of data



Using the code below, I'm getting two different results:



  • When where username = '$username' is presented on the PHP side, I receive just the Toast message. However, ListView remains empty.


  • When I remove where username = '$username' from PHP side, Toast message is displayed and the ListView also shows some content


Could you please help me to undestand why the ListView remains empty on that specific case?



Thanks in advance



Java



public void current_user() 
String url = "http://websie/my.php";

Calendar calendar = Calendar.getInstance();
SimpleDateFormat dayes = new SimpleDateFormat("dd-MM-yyyy");
final String created_date = dayes.format(calendar.getTime());

StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>()
@Override
public void onResponse(String response)
//System.out.println(response);
// Toast.makeText(MainActivity.this,response,Toast.LENGTH_SHORT).show();
Toast.makeText(show_post_all_sales_2x100.this, response.toString(), Toast.LENGTH_SHORT).show();

progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);


, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(show_post_all_sales_2x100.this, error.toString(), Toast.LENGTH_SHORT).show();

)
@Override
protected Map<String, String> getParams()
Map<String, String> params = new HashMap<String, String>();
params.put("username", User.getUsername());
params.put("created_date", created_date);
return params;

;

RequestQueue requestQueue = com.android.volley.toolbox.Volley.newRequestQueue(this);
requestQueue.add(stringRequest);


private class ParseJSonDataClass extends AsyncTask<Void, Void, Void>
public Context context;
String FinalJSonResult;

public ParseJSonDataClass(Context context)
this.context = context;


@Override
protected void onPreExecute()
super.onPreExecute();


@Override
protected Void doInBackground(Void... arg0)

HttpParseClass httpParseClass = new HttpParseClass(HttpURL);

try
httpParseClass.ExecutePostRequest();

if (httpParseClass.getResponseCode() == 200)

FinalJSonResult = httpParseClass.getResponse();

if (FinalJSonResult != null)

JSONArray jsonArray = null;
try

jsonArray = new JSONArray(FinalJSonResult);
JSONObject jsonObject;
Subjects subjects;
SubjectList = new ArrayList<Subjects>();

for (int i = 0; i < jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
String tempName = jsonObject.getString("username").toString();
String tempFullForm = jsonObject.getString("created_date").toString();
subjects = new Subjects(tempName, tempFullForm);
SubjectList.add(subjects);

catch (JSONException e)
// TODO Auto-generated catch block
e.printStackTrace();


else
Toast.makeText(context, httpParseClass.getErrorMessage(), Toast.LENGTH_SHORT).show();

catch (Exception e)
e.printStackTrace();

return null;


@Override
protected void onPostExecute(Void result)
progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);




PHP



<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'DatabaseConfig.php';
$username = $_POST['username'];

// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);


$sql = "SELECT * FROM post_2x where username = '$username'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);

else
echo "No Results Found.";

echo $json;
$conn->close();

?>


Result when where username = '$username' is present



This image when i use (where username = username)



Result when I remove where username = '$username'



This image when i remove (where username = username)










share|improve this question
























  • This looks like Android. You might need to add that tag.

    – Sedrick
    Mar 26 at 17:57






  • 1





    i did thanks ..

    – vorta plus
    Mar 26 at 18:04











  • i need answer...

    – vorta plus
    Apr 2 at 15:57













0












0








0








I have an app where I use the info provided by the user to get a list of data



Using the code below, I'm getting two different results:



  • When where username = '$username' is presented on the PHP side, I receive just the Toast message. However, ListView remains empty.


  • When I remove where username = '$username' from PHP side, Toast message is displayed and the ListView also shows some content


Could you please help me to undestand why the ListView remains empty on that specific case?



Thanks in advance



Java



public void current_user() 
String url = "http://websie/my.php";

Calendar calendar = Calendar.getInstance();
SimpleDateFormat dayes = new SimpleDateFormat("dd-MM-yyyy");
final String created_date = dayes.format(calendar.getTime());

StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>()
@Override
public void onResponse(String response)
//System.out.println(response);
// Toast.makeText(MainActivity.this,response,Toast.LENGTH_SHORT).show();
Toast.makeText(show_post_all_sales_2x100.this, response.toString(), Toast.LENGTH_SHORT).show();

progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);


, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(show_post_all_sales_2x100.this, error.toString(), Toast.LENGTH_SHORT).show();

)
@Override
protected Map<String, String> getParams()
Map<String, String> params = new HashMap<String, String>();
params.put("username", User.getUsername());
params.put("created_date", created_date);
return params;

;

RequestQueue requestQueue = com.android.volley.toolbox.Volley.newRequestQueue(this);
requestQueue.add(stringRequest);


private class ParseJSonDataClass extends AsyncTask<Void, Void, Void>
public Context context;
String FinalJSonResult;

public ParseJSonDataClass(Context context)
this.context = context;


@Override
protected void onPreExecute()
super.onPreExecute();


@Override
protected Void doInBackground(Void... arg0)

HttpParseClass httpParseClass = new HttpParseClass(HttpURL);

try
httpParseClass.ExecutePostRequest();

if (httpParseClass.getResponseCode() == 200)

FinalJSonResult = httpParseClass.getResponse();

if (FinalJSonResult != null)

JSONArray jsonArray = null;
try

jsonArray = new JSONArray(FinalJSonResult);
JSONObject jsonObject;
Subjects subjects;
SubjectList = new ArrayList<Subjects>();

for (int i = 0; i < jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
String tempName = jsonObject.getString("username").toString();
String tempFullForm = jsonObject.getString("created_date").toString();
subjects = new Subjects(tempName, tempFullForm);
SubjectList.add(subjects);

catch (JSONException e)
// TODO Auto-generated catch block
e.printStackTrace();


else
Toast.makeText(context, httpParseClass.getErrorMessage(), Toast.LENGTH_SHORT).show();

catch (Exception e)
e.printStackTrace();

return null;


@Override
protected void onPostExecute(Void result)
progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);




PHP



<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'DatabaseConfig.php';
$username = $_POST['username'];

// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);


$sql = "SELECT * FROM post_2x where username = '$username'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);

else
echo "No Results Found.";

echo $json;
$conn->close();

?>


Result when where username = '$username' is present



This image when i use (where username = username)



Result when I remove where username = '$username'



This image when i remove (where username = username)










share|improve this question
















I have an app where I use the info provided by the user to get a list of data



Using the code below, I'm getting two different results:



  • When where username = '$username' is presented on the PHP side, I receive just the Toast message. However, ListView remains empty.


  • When I remove where username = '$username' from PHP side, Toast message is displayed and the ListView also shows some content


Could you please help me to undestand why the ListView remains empty on that specific case?



Thanks in advance



Java



public void current_user() 
String url = "http://websie/my.php";

Calendar calendar = Calendar.getInstance();
SimpleDateFormat dayes = new SimpleDateFormat("dd-MM-yyyy");
final String created_date = dayes.format(calendar.getTime());

StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>()
@Override
public void onResponse(String response)
//System.out.println(response);
// Toast.makeText(MainActivity.this,response,Toast.LENGTH_SHORT).show();
Toast.makeText(show_post_all_sales_2x100.this, response.toString(), Toast.LENGTH_SHORT).show();

progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);


, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Toast.makeText(show_post_all_sales_2x100.this, error.toString(), Toast.LENGTH_SHORT).show();

)
@Override
protected Map<String, String> getParams()
Map<String, String> params = new HashMap<String, String>();
params.put("username", User.getUsername());
params.put("created_date", created_date);
return params;

;

RequestQueue requestQueue = com.android.volley.toolbox.Volley.newRequestQueue(this);
requestQueue.add(stringRequest);


private class ParseJSonDataClass extends AsyncTask<Void, Void, Void>
public Context context;
String FinalJSonResult;

public ParseJSonDataClass(Context context)
this.context = context;


@Override
protected void onPreExecute()
super.onPreExecute();


@Override
protected Void doInBackground(Void... arg0)

HttpParseClass httpParseClass = new HttpParseClass(HttpURL);

try
httpParseClass.ExecutePostRequest();

if (httpParseClass.getResponseCode() == 200)

FinalJSonResult = httpParseClass.getResponse();

if (FinalJSonResult != null)

JSONArray jsonArray = null;
try

jsonArray = new JSONArray(FinalJSonResult);
JSONObject jsonObject;
Subjects subjects;
SubjectList = new ArrayList<Subjects>();

for (int i = 0; i < jsonArray.length(); i++)
jsonObject = jsonArray.getJSONObject(i);
String tempName = jsonObject.getString("username").toString();
String tempFullForm = jsonObject.getString("created_date").toString();
subjects = new Subjects(tempName, tempFullForm);
SubjectList.add(subjects);

catch (JSONException e)
// TODO Auto-generated catch block
e.printStackTrace();


else
Toast.makeText(context, httpParseClass.getErrorMessage(), Toast.LENGTH_SHORT).show();

catch (Exception e)
e.printStackTrace();

return null;


@Override
protected void onPostExecute(Void result)
progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(show_post_all_sales_2x100.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);




PHP



<?php
if($_SERVER['REQUEST_METHOD']=='POST')
include 'DatabaseConfig.php';
$username = $_POST['username'];

// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);


$sql = "SELECT * FROM post_2x where username = '$username'" ;
$result = $conn->query($sql);
if ($result->num_rows >0)
while($row[] = $result->fetch_assoc())
$tem = $row;
$json = json_encode($tem);

else
echo "No Results Found.";

echo $json;
$conn->close();

?>


Result when where username = '$username' is present



This image when i use (where username = username)



Result when I remove where username = '$username'



This image when i remove (where username = username)







java php android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 19:06









W0rmH0le

11.6k5 gold badges39 silver badges52 bronze badges




11.6k5 gold badges39 silver badges52 bronze badges










asked Mar 26 at 17:45









vorta plusvorta plus

13 bronze badges




13 bronze badges












  • This looks like Android. You might need to add that tag.

    – Sedrick
    Mar 26 at 17:57






  • 1





    i did thanks ..

    – vorta plus
    Mar 26 at 18:04











  • i need answer...

    – vorta plus
    Apr 2 at 15:57

















  • This looks like Android. You might need to add that tag.

    – Sedrick
    Mar 26 at 17:57






  • 1





    i did thanks ..

    – vorta plus
    Mar 26 at 18:04











  • i need answer...

    – vorta plus
    Apr 2 at 15:57
















This looks like Android. You might need to add that tag.

– Sedrick
Mar 26 at 17:57





This looks like Android. You might need to add that tag.

– Sedrick
Mar 26 at 17:57




1




1





i did thanks ..

– vorta plus
Mar 26 at 18:04





i did thanks ..

– vorta plus
Mar 26 at 18:04













i need answer...

– vorta plus
Apr 2 at 15:57





i need answer...

– vorta plus
Apr 2 at 15:57












0






active

oldest

votes










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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363336%2fhow-do-i-get-current-users-input-data-to-show-in-listview%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363336%2fhow-do-i-get-current-users-input-data-to-show-in-listview%23new-answer', 'question_page');

);

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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현