Commit d4246d9d authored by melvinfonda's avatar melvinfonda
Browse files

benerin findoffer

parent c3d07c6c
......@@ -400,17 +400,18 @@ public class MySQLAccess {
public JSONObject findOffer(int id_item) throws JSONException {
open();
JSONObject response = new JSONObject();
JSONArray offers = new JSONArray();
try {
preparedStatement = connect.prepareStatement("SELECT * FROM offer WHERE "
+ "offered_item=" + id_item + " AND available = 1;");
resultSet = preparedStatement.executeQuery();
while(resultSet.next()) {
int user_id = resultSet.getInt("id_user");
if(user_id != 0)
{
response.put("status", "ok");
JSONArray array = new JSONArray();
array.put(resultSet.getInt("offered_item"));
array.put(resultSet.getInt("n1"));
......@@ -418,9 +419,11 @@ public class MySQLAccess {
array.put(resultSet.getInt("n2"));
array.put(resultSet.getBoolean("available"));
array.put(resultSet.getString("offer_token"));
response.put("offers", array);
offers.put(array);
}
}
response.put("status", "ok");
response.put("offers",offers);
} catch (SQLException e) {
response.put("status", "error");
e.printStackTrace();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment