当数据库字段为空/空时,相应的文本应变为不可见 [英] when database field is null/empty then corresponding text should become invisible

查看:72
本文介绍了当数据库字段为空/空时,相应的文本应变为不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

when database field is null/empty then corresponding text should become invisible


 I have developed a web page in front page and using vbscript t language and database in MS acess .

in front page I have used dropdown menu which display plant name 

when we select any plant name from list it will display corresponding information on the web page i.e

Plant name: 

Trade name:

Synonyms:

uses : 


my code is like this :b>Plant name :<%=rs1("plantname")%><br />
b>Trade name :<%=rs1("tradename")%><br />
Synonyms   :<%=rs1("synonym1")%> <%=rs1("synonym2")%> <%=rs1("synonym3")%> <%=rs1("synonym4")%> <%=rs1("synonym5")%>
<%=rs1("synonym6")%><br />
Uses<br />
<textarea  readonly="readonly" name="S1" 

        style="width: 322px; height: 246px;"><%=rs1("uses1")%> <%=rs1("uses2")%> <%=rs1("uses3")%></textarea><br>



this code is working fine information on the basis of plant selection is working.

but the text which i have written above as Trade name ,Plant name ,uses etc .

I want that when I select a particular plant from the list and its related information is null/empty then that particular text will also get disappear. means if there is no information then there should be no heading or text for it.

please solve this answer .</br>

推荐答案

要检查空值,可以在从查询数据库中检索数据的同时添加代码.

你可以做...
To check for null value, you can add codes while retrieving data from database in query.

You can do like...
SELECT ISNULL(PlantName, '') as PlantName,
       ISNULL(TradeName, '') as TradeName,
       ISNULL(Synonyms, '') as Synonyms,
       ISNULL(uses, '') as uses,
FROM Plant_Details
WHERE PlantId = @PlantId


因此,ISNULL检查第一个参数(例如PlantName),如果它为NULL,则它将返回第二个参数,在这种情况下为空白('''').

然后从数据库获取值后,您可以显示相同的...

编码愉快...:)


So, ISNULL checks the first parameter (ex. PlantName) and if it is NULL, then it will return the second parameter, which is blank in this case ('''').

Then after getting the values from the DB u can show the same...

Happy coding... :)


这篇关于当数据库字段为空/空时,相应的文本应变为不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆