dcjones
08-23-2005, 03:07 PM
Hi all,
I have a database which holds addresses.
The fields are:
address1 = (street)
address2 = (suburb)
address3 = (town)
address4 = (county)
address5 = (zip code)
What I want to do is, when the output is displayed -
if address1 is empty display address2
if address2 is empty display address3
if address3 is empty display address4
if address4 is empty display address5
if address5 is empty display black space
mysql_select_db($database_accomm, $accomm);
$query_accomm_counties = sprintf("SELECT * FROM accom WHERE name = '%s' ORDER BY pic DESC", $colname_accomm_counties);
$query_limit_accomm_counties = sprintf("%s LIMIT %d, %d", $query_accomm_counties, $startRow_accomm_counties, $maxRows_accomm_counties);
$accomm_counties = mysql_query($query_limit_accomm_counties, $accomm) or die(mysql_error());
$row_accomm_counties = mysql_fetch_assoc($accomm_counties);
I have tried to do this with:
<?php
if (strlen ($row_accomm_counties['address1']) == 0)
{
echo $row_accomm_counties['address2'];
}
else
{
echo $row_accomm_counties['address1'];
}
if (strlen ($row_accomm_counties['address2']) == 0)
{
echo $row_accomm_counties['address3'];
}
else
{
echo $row_accomm_counties['address2'];
}
?>
--- and so on.
yes I know, it don't work.
Can soneone point me in the right direction.
Many thanks in advance, keep safe and well.
Dereck
}
I have a database which holds addresses.
The fields are:
address1 = (street)
address2 = (suburb)
address3 = (town)
address4 = (county)
address5 = (zip code)
What I want to do is, when the output is displayed -
if address1 is empty display address2
if address2 is empty display address3
if address3 is empty display address4
if address4 is empty display address5
if address5 is empty display black space
mysql_select_db($database_accomm, $accomm);
$query_accomm_counties = sprintf("SELECT * FROM accom WHERE name = '%s' ORDER BY pic DESC", $colname_accomm_counties);
$query_limit_accomm_counties = sprintf("%s LIMIT %d, %d", $query_accomm_counties, $startRow_accomm_counties, $maxRows_accomm_counties);
$accomm_counties = mysql_query($query_limit_accomm_counties, $accomm) or die(mysql_error());
$row_accomm_counties = mysql_fetch_assoc($accomm_counties);
I have tried to do this with:
<?php
if (strlen ($row_accomm_counties['address1']) == 0)
{
echo $row_accomm_counties['address2'];
}
else
{
echo $row_accomm_counties['address1'];
}
if (strlen ($row_accomm_counties['address2']) == 0)
{
echo $row_accomm_counties['address3'];
}
else
{
echo $row_accomm_counties['address2'];
}
?>
--- and so on.
yes I know, it don't work.
Can soneone point me in the right direction.
Many thanks in advance, keep safe and well.
Dereck
}