Forum Moderators: coopster
The first code works now but doesn't have a "rule" that is pasted below.
Appreciate your help
}
echo '<td><ul>';
echo '<LI STYLE="list-style-type: circle"> <b>player:</b> ';
echo $book['player'];
echo '<LI STYLE="list-style-type: circle"><b>team:</b> ';
echo $book['team'];
echo '<LI STYLE="list-style-type: circle"><b>current value:</b> ';
echo number_format($book['value'], 2);
echo '<LI STYLE="list-style-type: circle"><b>description:</b> ';
echo $book['description'];
echo '</ul></td></tr></table>';
}
if($value[0]>0)
echo '<LI STYLE="list-style-type: circle"><b>current value:</b> ';
echo number_format($book['value'], 2);
Like wise if the description equals "1" then it shoudn't be displayed.
The recommended code worked once then the got many errors.
}
echo '<td><ul>';
echo '<LI STYLE="list-style-type: circle"> <b>player:</b> ';
echo $book['player'];
echo '<LI STYLE="list-style-type: circle"><b>team:</b> ';
echo $book['team'];
echo '<LI STYLE="list-style-type: circle"><b>current value:</b> ';
echo number_format($book['value'], 2);
echo '<LI STYLE="list-style-type: circle"><b>description:</b> ';
echo $book['description'];
echo '</ul></td></tr></table>';
}
else
echo 'The details of this book cannot be displayed at this time.';
echo '<hr />';
}
so I am sure the code isn't right but in theory
if ($book['value'] >= 1 {
echo '<LI STYLE="list-style-type: circle"><b>current value:</b> ';
echo number_format($book['value'], 2);
}
else
{
don't show value ($book['value'])
if $book['description']!= 'none') {
echo '<LI STYLE="list-style-type: circle"><b>description:</b> ';
echo $book['description'];
}
else
{
Don't show description ($book['description'])
Well, your theory is correct -- and your code is close, just complete the
elsepart of your logic and close the statement with and ending brace (}) and test it. You should get the desired results by the looks of it.
//check for a value, if there is one, display it.
if ($book['value'] >= 1) {
echo '<LI STYLE="list-style-type: circle"><b>current value:</b> ';
echo number_format($book['value'], 2);
}
//check for a description, if there is one, display it.
if ($book['description']!= 'none') {
echo '<LI STYLE="list-style-type: circle"><b>description:</b> ';
echo $book['description'];
}
will work just fine. When you use an if and no else, php evaluates the if and if it is true, executes the code. If it is false, it just moves the to next set of code.
There are also some other ways to make sure the fields are not empty. For example, I might use:
if ($book['description']!= "" OR NULL)
HTH
Mark