I would like to include a condition in the sql query, follows.
$Q_horario = "SELECT ".
" H.horario As horario, ".
" L.codigo As codlinha, ".
" L.descricao As linha, ".
" L.tipo As tipo, ".
" IF (H.sentido='I',L.saida,L.chegada) As saida, ".
" IF (H.sentido='I',L.chegada,L.saida) As chegada, ".
" T. valor As tarifa ".
"FROM tarifas T ".
" INNER JOIN linhas L ON L.codigo = T.linha ".
" INNER JOIN horarios H ON H.linha = L.codigo ".
if ($entra == 3){
"INNER JOIN cidade C on C.origem = T.origem AND C.destino = T.destino ".
"AND C.entra = 'N' ".
"AND C.diasemana = 'DOM'".
"AND C.horario = H.horario".
}
"WHERE T.origem = $origem ".
" AND T.destino= $destino ".
" AND H.sentido = '$sentido'".
" AND ((MID(H.frequencia, '$dia', 1) = 'S') AND (MID(H.frequencia1002, '$dia', 1) = 'S')) ".
"ORDER BY T.linha, H.horario ";
Would you have any way to include this if ?, type a filter;
because of this form of syntax error