[PHP-DB] Suppressing NULL values in search results

2001-02-19 Thread Cameron Metcalf

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
titleSearch Results/title
link REL="stylesheet" HREF="styles/bibnetstyle.css"
/head
body
?php 
include ("styles/bibnethd-e.html")
?
table width="90%" border="0"
trtd width="20%" valign="top"?php 
include ("styles/bibnetnav-e.html")
?/tdtd 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 ("trtd bgcolor=\"#9C\"font size=\"5\"
color=\"#FF\"$base[0]/font/td/trtrtdfont
color=\"#00\"bDate Range:/bnbsp;$base[1]/fontbrfont
color=\"#00\"bAccess Type:/b/fontnbsp;font
color=\"#ff\"b$base[2]/b/fontpfont color=\"#00\"a
href=\"$base[5]\"Connect to $base[0]/a/fontp
a href=\"instructions-e.php?access=$base[2]\"Instructions to connect
to this database from off campus./apfont
color=\"#00\"bDescription of
$base[0]:/bnbsp;$base[3]/fontfont color=\"#00\"pbSubjects
covered in $base[0]:/bnbsp;$base[4]/font/td/tr\n"); 
}
?
/table/td/tr
trtd colspan="2" valign="top"
?php 
include ("styles/bibnetft-e.html")
?/td/tr
trtd colspan="2" valign="top"?php 
include ("dinclude.php")
?/td/tr/table
/BODY
/HTML

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Suppressing NULL values in search results

2001-02-19 Thread Lennin Arriola


I used to do this:

function nice( $value )
{
   if ($value=="")
   {
 return "-nbsp;";
   }
   else return $value;
}

print nice($row["company"])

Lennin Arriola
[EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]