How to get the rowcount from php file in android -


i'm comparing username , password user input database data, , used count check if equal 1 or 0.

if it's equal 1, edittext should set 1, , if it's 0 should set 0.

my problem is, it's set 0 if username , password correct.

here name value pair , connection database:

    username = etlogusername.gettext().tostring();     password = etlogpassword.gettext().tostring();     string output = "";  //setting namevaluepair             list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(1);              //adding string variables inside namevaluepairs             namevaluepairs.add(new basicnamevaluepair("user_username", username));             namevaluepairs.add(new basicnamevaluepair("user_password", password));             httpclient httpclient = new defaulthttpclient();             httppost httppost = new httppost("http://thesis-account.byethost7.com/workout_select_username.php");             httppost.setentity(new urlencodedformentity(namevaluepairs));              //getting response             httpresponse response = httpclient.execute(httppost);              //setting entity             httpentity entity = response.getentity();              = entity.getcontent(); 

here json read data:

jsonarray jarray= new jsonarray(output);              for(int = 0;  <jarray.length() ; i++){                 jsonobject json = jarray.getjsonobject(i);                 count_user_id = json.getint("num_rows");                  if(count_user_id == 1)                 {                  isequal = true;                 }             }             etlogusername.settext(count_user_id+""); 

and here php file:

$sql = mysql_query("select count(user_id) num_rows tbl_users user_username='{ $username}' && user_password = '{$password}' "); while($row=mysql_fetch_assoc($sql)) { $output[]=$row; } print(json_encode($output)); mysql_close($con); 


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -