I am hoping someone can steer me towards an elegant solution to a
simple problem.
I have a query result which returns an array of details about a
physical building, including its address. The relevant fields are:
$row[houseNo]
$row[street]
$row[town]
$row[city]
$row[county]
$row[postcode]
I want to print the address in the usual html format. i.e.
houseNo<br/>
street<br/>
town<br/>
etc
*but* if the field is empty (e.g. the address is in London - no town
field required) I do not want a blank row in my html.
I can think of various ways to do this, but they are all very
inelegant, e.g. 6 if clauses, each adding $row[] . "<br/>" if $row <>
"". Euch.
I guess what I want is a for loop, but how do I only loop through the
relevant $row[] values and ignore the non-address fields?
simple problem.
I have a query result which returns an array of details about a
physical building, including its address. The relevant fields are:
$row[houseNo]
$row[street]
$row[town]
$row[city]
$row[county]
$row[postcode]
I want to print the address in the usual html format. i.e.
houseNo<br/>
street<br/>
town<br/>
etc
*but* if the field is empty (e.g. the address is in London - no town
field required) I do not want a blank row in my html.
I can think of various ways to do this, but they are all very
inelegant, e.g. 6 if clauses, each adding $row[] . "<br/>" if $row <>
"". Euch.
I guess what I want is a for loop, but how do I only loop through the
relevant $row[] values and ignore the non-address fields?
Comment