Jump to content

Recommended Posts

Posted

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>

Posted

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.

Posted

<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>

Posted

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?

Posted

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>
Posted

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.

Posted
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

Posted (edited)

tens q ter ( ) para o if todo

If ((($exibe['MedicaValidade'] != '0000-00-00')) && ((strtotime($exibe['MedicaValidade']) < time()))) {
Edited by edazevedo
Posted

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'

Posted
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

Posted (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 by mkurt11
Posted

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>';

}

}

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.