if field is empty don't display the link (or field)

From: Date: Fri, 18 Apr 2003 11:39:53 +0000
Subject: if field is empty don't display the link (or field)
Groups: php.general 
Request: Send a blank email to php-general+get-144397@lists.php.net to get a copy of this message
Hi All, Can you please help me with the following? What i'm trying to do is; when a field of an query is empty don't display. But if the field has a value, display a link. The result of the following code i've written is: When all fields or if one of the tree fields is filled in , all three 'menu options' are displayed. For the good order; what I want is this: when only the field 'eten' has a value, only that link is displayed. Here is the code: <html> <head> <title>Menu</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <? // includes include("../conf/config.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $stedenid=$_GET['stedenid']; // generate and execute query $query2 = "SELECT stedenid, naamstad, geschiedenis, eten, vervoer, omgeving FROM steden WHERE publiceer='yes' AND stedenid = $stedenid"; $result2 = mysql_query($query2) or die ("Error in query: $query2. " . mysql_error()); $row2=mysql_fetch_object($result2); if (isset($row2->geschiedenis)) { ?> <a href="steden.php?stedenid=<? echo $row2->stedenid; ?>&subj=geschiedenis">Geschiedenis</a></font> <? } if (isset($row2->eten)) { ?> <a href="steden.php?stedenid=<? echo $row2->stedenid; ?>&subj=eten">Eten</a></font> <? } if (isset($row2->vervoer)) { ?> <a href="steden.php?stedenid=<? echo $row2->stedenid; ?>&subj=vervoer">Vervoer</a></font> <? } else; ?> </body> </html> Thanks for your help! Frank

« previous php.general (#144397) next »