<?php
//Get the name of the Method
//The method name has to be passed as Method via post
$Request_Method=$_REQUEST['method'] or die('Method name not found');
$HOST = "host";
$USER = "user";
$PASSWORD = "password";
$DATABASE = "database";
//Connect to the database
$Connection = mysql_connect($HOST,$USER,$PASSWORD) or die('Cannot connect to Database');
//Select the database
mysql_select_db("booking") or die('Cannot select Database');
//Get all th employees that are managed the by the given emplyee
if($Request_Method=="getCitas")
{
$id=$_REQUEST['id'];
$query="select name from bokking where id=$id";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
$resultArray[] = $row;
}
echo json_encode($resultArray);
}
//Close Connection
mysql_close($Connection);
?>
--
Para participar es necesario que leas detenidamente las normas del grupo: http://goo.gl/20KhL
---
Has recibido este mensaje porque estás suscrito al grupo "desarrolladores-android" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus correos electrónicos, envía un correo electrónico a desarrolladores-a...@googlegroups.com.
Para publicar una entrada en este grupo, envía un correo electrónico a desarrollad...@googlegroups.com.
Visita este grupo en http://groups.google.com/group/desarrolladores-android?hl=es.
Para ver este debate en la Web, visita https://groups.google.com/d/msgid/desarrolladores-android/9e073eff-7213-4a26-9612-f363a4777205%40googlegroups.com?hl=es.
Para obtener más opciones, visita https://groups.google.com/groups/opt_out.
public class ServerAccess {
// Convert an inputstream to a string
public static String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
Log.e("PHP Client", "Error : " + e.getMessage());
} finally {
try {
is.close();
} catch (IOException e1) {
Log.e("PHP Client", "Error : " + e1.getMessage());
}
}
return sb.toString();
}
// Get the response form the server as an object
public Object getResponseObject(ArrayList<NameValuePair> Parameters, Class c) {
try {
// Create a HTTP Client
HttpClient httpclient = new DefaultHttpClient();
// Create and object to Post values to the server
// The url is specified in the Constants class to increase
// modifiability
HttpPost httppost = new HttpPost(Constants.SERVICE_URL);
// Set the attributes to be posted as Parameters
httppost.setEntity(new UrlEncodedFormEntity(Parameters));
// Execute the post and get the response
HttpResponse response = httpclient.execute(httppost);
// Get the response as ans entity
HttpEntity entity = response.getEntity();
// Get the content of the response as a stream
InputStream stream = entity.getContent();
// Convert the stream to a GSON object
String result = convertStreamToString(stream);
// Create a GSON object
Gson gson = new Gson();
// Convert the respose string to a object of the given type
// Here Object class is used so that we can use the same method to
// get any
// class's object as response
Object responseObject = gson.fromJson(result, c);
// Return the object
return responseObject;
} catch (Exception e) {
Log.e("PHP Client", "Error in http connection" + e.toString());
return null;
}
}
// Verify the login and return user id or 0
// Get the employees
public Booking[] getBooking(String code) {
// Create the arraylist to set the parameters of the post
ArrayList<NameValuePair> parameters = new ArrayList<NameValuePair>();
// Set the method name
parameters.add(new BasicNameValuePair("method", "getBooking"));
parameters.add(new BasicNameValuePair("code", code));
// Get the array of employee arrays as the result
Booking[] o = (Booking[]) getResponseObject(parameters, Booking[].class);
return o;
}
public void setReservaHora(String code, String hora) {
ArrayList<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("method", "setReservarHora"));
parameters.add(new BasicNameValuePair("code", code));
parameters.add(new BasicNameValuePair("hora", hora));
}
}
Bueno, buscándome la vida por otros lados ya he conseguido que me funcione todo correctamente. Solo me falta implementar un ProgressDialog, pero no se como implementarlo ya que tengo una clase que es la dedicada a conectarse al webservice y ejecutar el método que yo le pida que se llama ServerAccess. Desde la clase de la activity hago un ServerAccess ss = new ServerAccess(); y guardo los resultados del método getDatos en un array Datos[] datos = ss.getDatos(codigo); Donde debería configurar el ProgressDialog y como lo configuro?Muchas Gracias
--
Para participar es necesario que leas detenidamente las normas del grupo: http://goo.gl/20KhL
---
Has recibido este mensaje porque estás suscrito al grupo "desarrolladores-android" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus correos electrónicos, envía un correo electrónico a desarrolladores-a...@googlegroups.com.
Para publicar una entrada en este grupo, envía un correo electrónico a desarrollad...@googlegroups.com.
Visita este grupo en http://groups.google.com/group/desarrolladores-android?hl=es.
Para ver este debate en la Web, visita https://groups.google.com/d/msgid/desarrolladores-android/2e0697f4-6acd-4971-930e-6936b31568c5%40googlegroups.com?hl=es.