Forums

Hiding fields

mirkogeo 01 Oct, 2009
How can I hide a field (province) if this field is equal to the city (city)?
if {province} = {city} ??????


Thanks
GreyHead 01 Oct, 2009
Hi mirkogeo,

You'll need to add some PHP to check if the two values are the same. I don't think the {field_name} syntax witll work with the PHP so try this:
<?php
if ( $myRow->province == $MyRow->city ) {
  $province = $myRow->province;
} else {
  $province = $MyRow->city.", ".$MyRow->province;
}
echo $province;
?>

Bob
mirkogeo 01 Oct, 2009
Hi GeryHead
the code not work; this is the error:
Parse error: syntax error, unexpected '{', expecting '(' in /web/htdocs/www.geocaibassano.it/home/components/com_chronoconnectivity/libraries/connection.php(303) : eval()'d code on line 9
This is my body code:
<table width="100%" height="221" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <th height="27" colspan="2" bgcolor="#FFDF00" scope="col"><h5>{gruppo}</h5></th>
  </tr>
  <tr>
    <td width="304" bgcolor="#FFFFAA"><p>{indirizzo}</p>
    <p>{cap} - {paese} - {provincia}</p>
    <p>Telefono - {telefono}</p>
    <p><a target="_blank" href="{url_gruppo}">{url_gruppo}</a></p>
    <p><a href="mailto:{email_gruppo}">{email_gruppo}</a></p></td>
    <td width="130" align="center" valign="middle" bgcolor="#FFFFAA"><img src="components/com_chronocontact/uploads/gruppi_speleo_italia/{logo}"></td>
  </tr>
</table>

I would like hide field "provincia" when this is like "paese"
Where do I put the php code if it work?
In the WHERE SQL area or in BODY area?
I am newby in my sql and php language (also in english language).
Thanks for your help
GreyHead 01 Oct, 2009
Hi mirkogeo,

Sorry, a typo in there. The if line should be
if ( $myRow->province == $MyRow->city ) {


It needs to go into the body area.

Bob
mirkogeo 01 Oct, 2009
hi GreyHead
your code works but does not solve my problem because it does not hide the field "province" when it is equal to the "city".
Shows the field "city" and "province" always has to be equal whether they are different.
Mine is not a big problem and I left as is.
Thanks anyway for the help.
GreyHead 01 Oct, 2009
Hi mirkogeo,

I think you'll need to change the display code in the html as well (and check my logic).

Bob
This topic is locked and no more replies can be posted.