Suppressing NULL values in search results

From: Date: Mon, 19 Feb 2001 18:24:17 +0000
Subject: Suppressing NULL values in search results
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6753@lists.php.net to get a copy of this message
Hey, I've been using PHP for 'bout a month and my programming abilities are pretty limited. I'm using a script (further below) to retrieve results from a MySQL database. It's intended to retrieve potentially 6 fields of information. Some of these fields in the record, though, may be NULL, but then I get the word "NULL" on my web page If a field is NULL, how do I change this script, so that only those non-NULL fields are displayed? I've been reading up on arrays, but I can't figure out if my answer lies there, or in some section 'bout variable re-assignment. My hunch is I've got to create a print buffer of some sort, but I can't figure out how to do that either. In my database, p.nameE, u.urlE *are* required whereas p.daterange, a.accessE, p.descriptionE, p.subjectE, are not required and may have NULL values in my database. Direct solutions would be appreciated or even if you could suggest a name/terminology for this problem, because I've been unable to turn anything up in the archives/printed literature. Thanks for your time. Cameron ************ <html> <head> <title>Search Results</title> <link REL="stylesheet" HREF="styles/bibnetstyle.css"> </head> <body> <?php include ("styles/bibnethd-e.html") ?> <table width="90%" border="0"> <tr><td width="20%" valign="top"><?php include ("styles/bibnetnav-e.html") ?></td><td width="80%" valign="top"> <table width="100%" border="0"> <?php $select = mysql_select_db ("bases"); $query = "select p.nameE, p.daterange, a.accessE, p.descriptionE, p.subjectE, u.urlE from principle p, accesstype a, accessdetails ad, url u, urldetails ud where p.baseID='$baseID' and p.baseID = ad.baseID and ad.accessID = a.accessID and p.baseID = ud.baseID and ud.urlID = u.urlID"; $result = mysql_query ("$query"); while ($base = mysql_fetch_array ($result)) { print ("<tr><td bgcolor=\"#9C0000\"><font size=\"5\" color=\"#FFFFFF\">$base[0]</font></td></tr><tr><td><font color=\"#000000\"><b>Date Range:</b>&nbsp;$base[1]</font><br><font color=\"#000000\"><b>Access Type:</b></font>&nbsp;<font color=\"#ff0000\"><b>$base[2]</b></font><p><font color=\"#000000\"><a href=\"$base[5]\">Connect to $base[0]</a></font><p> <a href=\"instructions-e.php?access=$base[2]\">Instructions to connect to this database from off campus.</a><p><font color=\"#000000\"><b>Description of $base[0]:</b>&nbsp;$base[3]</font><font color=\"#000000\"><p><b>Subjects covered in $base[0]:</b>&nbsp;$base[4]</font></td></tr>\n"); } ?> </table></td></tr> <tr><td colspan="2" valign="top"> <?php include ("styles/bibnetft-e.html") ?></td></tr> <tr><td colspan="2" valign="top"><?php include ("dinclude.php") ?></td></tr></table> </BODY> </HTML>

« previous php.db (#6753) next »