mardi 30 décembre 2014

php select on two tables


Vote count:

0




I just started with webService in PHP and I'm a little lost.


I have two tables, service and voluntarioServicio. I want to get all the data of table service and also want to see if there is any voluntarioServicio table row containing the id field of table service and if so to give me the value of assistance voluntarioServicio column table.


Am you can help make the consultation? I know they are nested select but do not know how to use it well.


This is my code but it does not work well


CODE



$consulta = "SELECT tipo,nombre,descripcion,hora,minuto ,lugar,duracion,fecha,horacero,id,asistencia,ano,dia,mes FROM ( SELECT ".$tabla.".*, voluntarioServicio.asistencia FROM ".$tabla."
left join voluntarioServicio on (".$tabla.".id=voluntarioServicio.id)) as tabla ORDER BY ano,mes,dia,hora,minuto";
$resultado= mysql_query($consulta,$enlace);
$arraySalida = array();
while($registro = mysql_fetch_assoc ($resultado) ):

$cadena = "{$registro['tipo']};{$registro['nombre']};{$registro['descripcion']};{$registro['hora']};{$registro['minuto']};{$registro['lugar']};{$registro['duracion']};{$registro['fecha']};{$registro['horacero']};{$registro['asistencia']};{$registro['id']}";
$arraySalida[]= $cadena;
endwhile;

echo implode(":",$arraySalida);


Thanks for your time and help.



asked 1 min ago







php select on two tables

Aucun commentaire:

Enregistrer un commentaire