Forums

ASP

This topic is locked

How do I hide text if the DB field is empty?

Posted 20 May 2006 20:34:49
1
has voted
20 May 2006 20:34:49 Mike Ward posted:
Hi,

There's hopefully an easy answer to this question, but I'm stuck!!

I'm using an Access 2000 database to store my records. I want to display the data that is contained in the fields in a dynamic table created in Dreamweaver MX. So far I'm doing ok and everything works <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Now the bit I'm stuck on. Some records within the recordset contain no data in a certain field, while others do. How can I hide the fields for the records that have no data, but still display the field for those that do have data?

Any help appreciated.

Mike

Replies

Replied 21 May 2006 02:45:55
21 May 2006 02:45:55 micah santos replied:
&lt;%
// Display Records
// Note: field job_title & job_salary are empty values

Dim glName,glJob_title,glSalary

Set rsData = ObjConn.Execute("SELECT * FROM tblData ORDER BY id"

WHILE NOT rsData.EOF

// Check all fields before displaying values

If rsDate("name" &lt;&gt; "" Then
glName = rsDate("name" & "&lt;br&gt;"
End If

If rsDate("job_title" &lt;&gt; "" Then
glJob_title = rsDate("job_title" & "&lt;br&gt;"
End If

If rsDate("job_salary" &lt;&gt; "" Then
glSalaray = rsDate("job_salary" & "&lt;br&gt;"
End If

rsData.MoveNext
WEnd

// Display values

response.write glName & glJob_title & glSalary

rsData.Close
set rsData = Nothing

%&gt;
Replied 07 Jul 2006 23:36:08
07 Jul 2006 23:36:08 Mike Ward replied:
Hi Micah,

Thanks for your reply and sorry for the delayed response. I've now decided not to omit the blank fields. It was a little beyond my current understanding of ASP!! I'm a complete novice, so I'll stick to the basics for now. Thanks for your help anyway.

Mike

Reply to this topic