php - Android MYSQL Select * to Consctruct Java Object -
i trying retrieve data mysql database in android using following code:
... httpresponse response = httpclient.execute(httppost); bufferedreader in = new bufferedreader( new inputstreamreader(response.getentity() .getcontent())); stringbuffer sb = new stringbuffer(""); string line = ""; while ((line = in.readline()) != null) { sb.append(line); break; } in.close(); responsestring = sb.tostring(); responsestring = responsestring.substring(0, responsestring.length() - 1); showmessage(responsestring); system.out.println(responsestring); // handle response user.orderlist.clear(); string[] tmp1 = responsestring.split("\\|"); (string s : tmp1) { string[] tmp2 = s.split(","); order tmp3 = new order(); tmp3.orderid = tmp2[0]; tmp3.placername = tmp2[1]; tmp3.itemname = tmp2[2]; tmp3.payment = tmp2[3]; tmp3.locationstring = tmp2[4]; user.orderlist.add(tmp3); system.out.println(tmp3.tostring()); } ...
this gets response php file string , splits response based on , , | here php code returns data java code:
$sql = mysql_query("select * orders (location_lat between '".$_post['latmin']."' , '".$_post['latmax']."') , (location_long between '".$_post['longmin']."' , '".$_post['longmax']."')"); if($sql){ while($row = mysql_fetch_assoc($sql)) { echo ($row['order_id'] . "," . $row['placer_name'] . "," . $row['item_name'] . "," . $row['payment_amount'] . "," . $row['location_string'] . "|"); } } else{ echo 'failed. sql error occured.'; }
the issue reason getting 4 of values: placername, itemname, payment, locationstring. orderid not return anything.
database:
Comments
Post a Comment