In my android app. When i update the scores of teams, everything in the database updates. How can i get the id of a column in php and android? How can i update values in my database using android by getting the id?
PHP
<?php
$teamone = $_POST["teamone"];
$teamtwo = $_POST["teamtwo"];
$teamonepts = $_POST["teamonepts"];
$teamtwopts = $_POST["teamtwopts"];
require_once('init.php');
$sql = "UPDATE matches SET teamone = '$teamone', teamonepts = '$teamonepts', teamtwo = '$teamtwo', teamtwopts = '$teamtwopts'";
if(mysqli_query($con,$sql)){
echo 'Updated';
}else{
echo 'Failed';
}
mysqli_close($con);
?>
Here is my android code
else if(method.equals("send"))
{
String teamone = params[1];
String teamonepts = params[2];
String teamtwo = params[3];
String teamtwopts = params[4];
try {
URL url = new URL(send_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
OutputStream os = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
String data = URLEncoder.encode
("teamone", "UTF-8")+"="+ URLEncoder.encode(teamone, "UTF-8")+"&"+
URLEncoder.encode("teamonepts", "UTF-8")+"="+ URLEncoder.encode(teamonepts, "UTF-8")+"&"+
URLEncoder.encode("teamtwo", "UTF-8")+"="+ URLEncoder.encode(teamtwo, "UTF-8")+"&"+
URLEncoder.encode("teamtwopts", "UTF-8")+"="+ URLEncoder.encode(teamtwopts, "UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
os.close();
InputStream IS = httpURLConnection.getInputStream();
IS.close();
httpURLConnection.disconnect();
return "Data Sent";
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
Here is my table