joaorr1 Posted August 28, 2012 at 05:59 PM Report Share #473849 Posted August 28, 2012 at 05:59 PM (edited) Olá gostaria que me vissem o código e indicassem como por um if dentro deste código php. Não está a funcionar e necessito de criar vários else if. Sendo este só um exemplo de um else if. while($row = mysql_fetch_array($result)) { echo '<tr id="tit"> <th colspan="7" ><div id="divRefeicao">'.$row['nomeTipoRefeicao'].'</div></th> </tr>' if($row['nomeTipoRefeicao'] == "Almoco"){ $alim->printTblAlim(''.$row['nomeTipoRefeicao'].'', $_SESSION['data'], $idUti). } '<tr id="linhaEmBranco"> <td colspan="6"><div id="divBottom"></div></td> </tr>'; } } Sendo este o erro: Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in Cumprimentos João Rodrigues Edited August 28, 2012 at 06:17 PM by joaorr1 Link to comment Share on other sites More sharing options...
KiNgPiTo Posted August 28, 2012 at 06:13 PM Report Share #473855 Posted August 28, 2012 at 06:13 PM Não podes meter um if dentro de um echo dessa maneira... echo '<tr id="tit"> <th colspan="7" ><div id="divRefeicao">'.$row['nomeTipoRefeicao'].'</div></th> </tr>'; if($row['nomeTipoRefeicao'] == "Almoco") { echo $alim->printTblAlim(''.$row['nomeTipoRefeicao'].'', $_SESSION['data'], $idUti); }else{ echo "teste"; } Link to comment Share on other sites More sharing options...
joaocasta Posted August 28, 2012 at 06:17 PM Report Share #473857 Posted August 28, 2012 at 06:17 PM Boas joaorr1... Tenta interpretar o erro: "Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in" Diz que o if é inesperado, pois tu não fechaste com ";" o teu echo e os dois pontos que tens nao sao precisos acho. <?php echo '<tr id="tit"> <th colspan="7" ><div id="divRefeicao">'.$row['nomeTipoRefeicao'].'</div></th> </tr>'; if($row['nomeTipoRefeicao'] == "Almoco") { $alim->printTblAlim(''.$row['nomeTipoRefeicao'].'', $_SESSION['data'], $idUti); }else{ echo "teste"; } ?> Link to comment Share on other sites More sharing options...
joaorr1 Posted August 28, 2012 at 06:18 PM Author Report Share #473859 Posted August 28, 2012 at 06:18 PM (edited) Obrigadão!! Já funciona 🙂 Eu tinha tentado dessa maneira mas não me imprimia o que queria, faltava o echo ao chamar a função do meio. Cumprimentos e resto bom dia. Edited August 28, 2012 at 06:19 PM by joaorr1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now