klasss Posted June 6, 2014 at 10:07 AM Report #558425 Posted June 6, 2014 at 10:07 AM Bom dia, Estou com um pequeno problema e não estou a conseguir resolver pois eu apenas quero mostrar um campo se ele estiver preenchido: Parse error: syntax error, unexpected 'if' (T_IF), expecting ',' or ';' <p>if($exibe["Nome6"] != NULL) { echo' "<p><b>Nome: </b>'.$exibe["Nome6"].' <b> Função : </b>'.$exibe["Funcao6"]. }</p>
guarana1 Posted June 6, 2014 at 10:22 AM Report #558426 Posted June 6, 2014 at 10:22 AM Abriste as tags de php? Olha só, tens código html logo seguido por código php e nem abriste e fechaste a tag <?php / ?> E se já tiveres aberto as tags, tira o <p> e </p>, estás a por html em código php.
klasss Posted June 6, 2014 at 10:40 AM Author Report #558428 Posted June 6, 2014 at 10:40 AM mas o <p> e </p> funciona tambem em php. O codigo está todo dentro da tag <?php .. ?>
guarana1 Posted June 6, 2014 at 10:48 AM Report #558430 Posted June 6, 2014 at 10:48 AM Mete mais código, aquele que está acima desse.
klasss Posted June 6, 2014 at 10:51 AM Author Report #558432 Posted June 6, 2014 at 10:51 AM <p><b>Nome :</b> '.$exibe["Nome13"].' <b> Função : </b> '.$exibe["Funcao13"].'</p> <p><b>Nome :</b> '.$exibe["Nome14"].' <b> Função : </b> '.$exibe["Funcao14"].'</p> <p><b>Nome :</b> '.$exibe["Nome15"].' <b> Função : </b> '.$exibe["Funcao15"].'</p> <p><b>Nome :</b> '.$exibe["Nome16"].' <b> Função : </b> '.$exibe["Funcao16"].'</p> <p>' if($exibe["Nome6"] != NULL) { echo '<p><b>Nome: </b>'.$exibe["Nome6"].' <b> Função : </b>'.$exibe["Funcao6"]. }'</p>
guarana1 Posted June 6, 2014 at 10:56 AM Report #558434 Posted June 6, 2014 at 10:56 AM (edited) Se estás a imprimir o código html com um echo, então ainda tens de fecha-lo com um ; Edited June 6, 2014 at 11:04 AM by guarana1
klasss Posted June 6, 2014 at 11:46 AM Author Report #558445 Posted June 6, 2014 at 11:46 AM Já esta a funcionar. Não sei se me consegues ajudar noutra situação echo '<p><b>Nome: </b>'.$exibe["Nome6"].' <b> Função : </b>'.$exibe["Funcao6"]. nesse codigo quando tenho um nome maior ele fica desconfigurado em relação aos outros nomes. há forma de corrigir isso?
ajpostiga Posted June 6, 2014 at 12:39 PM Report #558447 Posted June 6, 2014 at 12:39 PM Bem se o nome é maior que os outros, vai ocupar mais espaço no ecrã. Já ponderou utilizar tabelas? Por defeito, as células de uma tabela ajustam-se automaticamente, em tamanho, para que todos os registos fiquem alinhados... Cumprimentos, José Postiga Software Engineer Follow me on Twitter: https://twitter.com/josepostiga
guarana1 Posted June 6, 2014 at 01:34 PM Report #558457 Posted June 6, 2014 at 01:34 PM Caso não saibas usar as tabelas. http://www.w3schools.com/html/html_tables.asp E aqui tens uma tabela "responsive" com css. <style> /* Generic Styling, for Desktops/Laptops */ table { width: 100%; border-collapse: collapse; } /* Zebra striping */ tr:nth-of-type(odd) { background: #eee; } th { background: #333; color: white; font-weight: bold; } td, th { padding: 6px; border: 1px solid #ccc; text-align: left; } /* Max width before this PARTICULAR table gets nasty This query will take effect for any screen smaller than 760px and also iPads specifically. */ @media only screen and (max-width: 760px), (min-device-width: 768px) and (max-device-width: 1024px) { /* Force table to not be like tables anymore */ table, thead, tbody, th, td, tr { display: block; } /* Hide table headers (but not display: none;, for accessibility) */ thead tr { position: absolute; top: -9999px; left: -9999px; } tr { border: 1px solid #ccc; } td { /* Behave like a "row" */ border: none; border-bottom: 1px solid #eee; position: relative; padding-left: 50%; } td:before { /* Now like a table header */ position: absolute; /* Top/left values mimic padding */ top: 6px; left: 6px; width: 45%; padding-right: 10px; white-space: nowrap; } /* Label the data */ td:nth-of-type(1):before { content: "Email"; } td:nth-of-type(2):before { content: "Nome"; } td:nth-of-type(3):before { content: "Número"; } td:nth-of-type(4):before { content: "Data"; } td:nth-of-type(5):before { content: "Nº pessoas"; } td:nth-of-type(7):before { content: "Parceiro"; } td:nth-of-type(6):before { content: "Informação adicional"; } td:nth-of-type(8):before {content: "Apagar"; } } </style>
klasss Posted June 6, 2014 at 03:00 PM Author Report #558473 Posted June 6, 2014 at 03:00 PM Agora estou a ter um erro noutro pedaço de codigo: If (($exibe['MedicaValidade'] != 0000-00-00) && ((strtotime($exibe['MedicaValidade']) < time())) { echo '<span style="color:red">'.$exibe['MedicaValidade'].'</span>'; echo 'Anexo: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a> } elseif ((strtotime($exibe['MedicaValidade']) >= time()) { echo '.$exibe['MedicaValidade'].'; echo 'Anexo: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a> } Parse error: syntax error, unexpected '{' in Tenho esse erro na primeira linha.
ajpostiga Posted June 6, 2014 at 03:28 PM Report #558479 Posted June 6, 2014 at 03:28 PM Parece que falta o fecho do if... Acrescenta um ')' antes da abertura do if... E aconselho a colocares aspas (ou plicas) onde tens 0000-00-00, de maneira a ficar '0000-00-00'. Cumprimentos, José Postiga Software Engineer Follow me on Twitter: https://twitter.com/josepostiga
edazevedo Posted June 6, 2014 at 04:13 PM Report #558484 Posted June 6, 2014 at 04:13 PM tens os 2 echos do "Anexo" em que a string não está fechada nem têm ; no final
klasss Posted June 6, 2014 at 04:14 PM Author Report #558485 Posted June 6, 2014 at 04:14 PM If (($exibe['MedicaValidade'] != '0000-00-00')) && ((strtotime($exibe['MedicaValidade']) < time())) { Agora mudou-me o erro.. e não sei porque Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in
edazevedo Posted June 6, 2014 at 04:16 PM Report #558486 Posted June 6, 2014 at 04:16 PM (edited) tens q ter ( ) para o if todo If ((($exibe['MedicaValidade'] != '0000-00-00')) && ((strtotime($exibe['MedicaValidade']) < time()))) { Edited June 6, 2014 at 04:17 PM by edazevedo
klasss Posted June 6, 2014 at 04:29 PM Author Report #558487 Posted June 6, 2014 at 04:29 PM If (($exibe['MedicaValidade'] != 0000-00-00) && ((strtotime($exibe['MedicaValidade']) < time()))) { echo '<span style="color:red">'.$exibe['MedicaValidade'].'</span>'; echo 'Anexo: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a>' } elseif ((strtotime($exibe['MedicaValidade']) >= time()) { echo '.$exibe['MedicaValidade'].'; echo 'PDF: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a> } Parse error: syntax error, unexpected 'MedicaValidade'
chbcl Posted June 7, 2014 at 10:49 PM Report #558592 Posted June 7, 2014 at 10:49 PM if (($exibe['MedicaValidade'] != 0000-00-00) && ((strtotime($exibe['MedicaValidade']) < time()))) { echo '<span style="color:red">'.$exibe['MedicaValidade'].'</span>'; echo 'Anexo: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a>'; } elseif ((strtotime($exibe['MedicaValidade']) >= time())) { echo '.$exibe['MedicaValidade'].'; echo 'Anexo: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a>'; } developer @ filipealves.net filipealvesbcl [a] gmail.com github.com/filipealvesbcl
mkurt11 Posted June 8, 2014 at 01:18 AM Report #558604 Posted June 8, 2014 at 01:18 AM (edited) if (($exibe['MedicaValidade'] != 0000-00-00) && ((strtotime($exibe['MedicaValidade']) < time()))) { echo '<span style="color:red">'.$exibe['MedicaValidade'].'</span>'; echo 'Anexo: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a>'; } elseif ((strtotime($exibe['MedicaValidade']) >= time())) { echo $exibe['MedicaValidade']; echo 'Anexo: <a href="MostrarMedica.php?id=' . $exibe['id'] . '">Ver PDF </a>'; } Esse é que está correto pois estava ali a concatenar nessa linha -> "echo $exibe['MedicaValidade'];" e não precisa, mas vê se limpas esse codigo pois está á uma confusão tremenda;) Edited June 8, 2014 at 01:19 AM by mkurt11
klasss Posted June 8, 2014 at 01:23 PM Author Report #558644 Posted June 8, 2014 at 01:23 PM Já alterei o codigo todo mas há uma coisa que ele não esta a fazer.. quando a data validade é igual a 0000-00-00 ou null eu quero que ele não me mostre nada. <?php echo '<div id="tabs-2">'; echo '<p><b>Ficha de Aptidão Médica:</b></p>'; echo '<p>Trabalhador (1) Validade:'; if ($exibe['MedicaValidade'] != '0000-00-00') { if (strtotime($exibe['MedicaValidade']) < time()) { echo '<span style="color:red">' . $exibe['MedicaValidade'] . '</span>'; echo 'Anexo :<a href="MostrarMedica.php?id=' . $exibe['id'] . '"> Ver PDF</a>'; } else { echo $exibe['MedicaValidade']; echo '<a href="MostrarMedica.php?id=' . $exibe['id'] . '"> Ver PDF</a></p>'; } } echo '<p>Trabalhador (2) Validade:'; if ($exibe['MedicaValidade2'] != '0000-00-00') { if (strtotime($exibe['MedicaValidade2']) < time()) { echo '<span style="color:red">' . $exibe['MedicaValidade2'] . '</span>'; echo '<a href="MostrarMedica2.php?id=' . $exibe['id'] . '"> Ver PDF</a>'; } else { echo $exibe['MedicaValidade2']; echo '<a href="MostrarMedica2.php?id=' . $exibe['id'] . '"> Ver PDF</a></p>'; } }
jlafuente Posted July 24, 2014 at 02:37 PM Report #563282 Posted July 24, 2014 at 02:37 PM Ora viva, Em vez de 2 if's tenta assim: if (($exibe['MedicaValidade2'] != '0000-00-00' || !is_null($exibe['MedicaValidade2'])) && strtotime($exibe['MedicaValidade2']) < time()) Abraços.
Devexz Posted July 24, 2014 at 08:10 PM Report #563307 Posted July 24, 2014 at 08:10 PM } elseif ((strtotime($exibe['MedicaValidade']) >= time()) { suponho que o erro esteja neste if, corrige os parentesis. Contador de calorias: caloriaspordia.com
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