<marquee behavior="alternate" scrolldelay="1" scrollamount="2">
<?php do { ?>
<?php echo $row_Recordset1['Name']; ?>:
<?php echo $row_Recordset1['Text']; ?>
•
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</marquee>
<?php mysql_free_result($Recordset1); ?>
0
A
回答
1
打印一个友好的信息给用户,而不是NULL
:
<?php echo (NULL === $row_Recordset1['Text']) ? "No value" : $row_Recordset1['Text']; ?>
由于xil3所示,您也可以使用此模式(from the docs):
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
+0
'($ row_Recordset1 ['Text']!='NULL')'这是错的!这是正确的:'($ row_Recordset1 ['Text']!== NULL)'见:http://php.net/manual/en/language.operators.comparison.php – Dolph 2010-07-06 21:40:38
1
你有它编写方式现在,$ row_Recordset1在第一次进入循环时将为空。
我已经改写为你:
<marquee behavior="alternate" scrolldelay="1" scrollamount="2">
<?php while($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?>
<?php echo (($row_Recordset1['Name'] != null) ? $row_Recordset1['Name'] : 'n/a'); ?>:
<?php echo (($row_Recordset1['Text'] != null) ? $row_Recordset1['Text'] : 'n/a'); ?>
•
<?php } ?>
</marquee>
<?php mysql_free_result($Recordset1); ?>
相关问题
- 1. 我能做些什么 PHP
- 2. 如果marker.setMap == null做些什么
- 3. -webkit-text-size-adjust做什么?
- 4. Phing能做些什么Ant不能?
- 5. 当child_added完成时会做些什么
- 6. `func.call(null,..)`做了什么?
- 7. 我能做些什么来解决java.lang.StringIndexOutOfBoundsException?
- 8. Codesign错误,我能做些什么?
- 9. 我能做些什么来避免NullPointerException?
- 10. Actionscript通讯文件能做些什么?
- 11. 当git push失败时,我能做些什么......“本地过时”?
- 12. 服务人员能做些什么,网络工作者不能做什么?
- 13. for循环结束时做些什么
- 14. 做些什么时,计数器= x
- 15. 在类上点击时做些什么
- 16. 终止python程序时做些什么
- 17. 音频停止时做些什么
- 18. Android:AlertDialog取消时做些什么
- 19. C:程序退出时做些什么
- 20. Angular2 - 在innerHTML改变时做些什么
- 21. 播放结束时做些什么
- 22. MsgBox关闭时做些什么
- 23. Xcode在索引时做些什么?
- 24. Mule - 在ArrayList为空时做些什么
- 25. 当$ .get完成时要做些什么
- 26. iOS:在收到UserNotification时做些什么?
- 27. WPF能做什么和不做什么?
- 28. 当buildbot在构建阶段失败时,我能做些什么
- 29. 当allow_store_upgrade失败时我能做些什么?
- 30. 我能做些什么! (感叹号)使用读主机时?
不是一个真正的问题?怎么会这样?正确的NULL值处理似乎很真实... – EFraim 2010-07-06 21:34:30
[
@EFraim我相信他们指的是$ row_Recordset1 ['Text'],在这种情况下,如果它是NULL,它最终可能只打印一个名称而没有后续文本。问题是关于怎么做,然后我猜... – 2010-07-06 21:36:37