2013-01-31 42 views
0

我有一個數據庫,我已成功連接到SQL,並將其顯示在我的網頁上。數據庫中有很多空字段,所以當我在瀏覽器的表格中顯示信息時,會看到很多空字段。我嘗試過使用空單元格功能,但這似乎不起作用。所以我想只在空字段中有「NULL」這個詞。如何在瀏覽器中查看數據時將空白字段輸入到空的HTML表格字段中?

我已經問過這個問題了,但是因爲我的問題有點模糊,所以關閉了。請參閱下面我的表碼:

<div id="displayBox" style="border: 3px solid #9C9595; height: 750; width: 1000px" class="blackBox"> 
<h2> View Sim Details </h2> 
<table class="myTable" border="5"> 
<tr> 
<th id="">ID</th> 
<th id="">Number</th> 
<th id="">Sim Card</th> 
<th id="">ACCOLC</th> 
<th id="">Notes</th> 
<th id="">Next Upgrade</th> 
<th id="">Pin</th> 
<th id="">Puk</th> 
<th id="">End Date</th> 
<th id="">Update</th> 
</tr> 
</div> 

回答

2

隨着ASP經典,你可以簡單地做這樣的事情:

<td><%=StringIfNull(rs("SomeValue"))%></td> 

function StringIfNull(value) 
    StringIfNull = value 

    if isnull(StringIfNull) then 
     StringIfNull = "Null" 
    end if 
end function 

或者你也可以在數據庫級別處理這個問題:

SELECT ISNULL(SomeValue, 'Null') AS SomeValue FROM MyTable 
相關問題