Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Part of code works, else doesn't 1

Status
Not open for further replies.

dmacster

Technical User
Jan 28, 2005
670
US
I have a field in mysql db called website - not all companies have them, so may be empty. I tested by setting up one entry as having a site that I know works, but when I try this, the category page show the paragraph returns for the empty fields, but doesn't echo the website field.

Code:
		 if (empty($row['website'])) {
   			 echo "<p>&nbsp;</>";
			} 
			else echo "<a href=\"[URL unfurl="true"]http://{$row[/URL]['website']}\">" . $row['website'] . "</a>";

Ideas?

thanks,
donna
 
could you try with the full syntax please
Code:
if (empty($row['website'])) {
  echo "<p>&nbsp;</>";
} else { 
  echo <<<HTML
   <a href="[URL unfurl="true"]http://{$row[/URL]['website']}">{$row['website']}</a>
HTML;
}
 
Your code works for me as is, so I guess the thing to check would be that the actual field "website" is being returned by your query.

Can we see some more code, like the query and the place where the $row variable is being set.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Never mind then

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I'd forgotten braces in the else, and in the end, jpadie had a more elegant solution to show it all. It worked fine before I added the else when testing (I was echoing a silly statement to view).

Works fine now.

Appreciate all the help and input.

Donna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top